home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / tcomm50.zip / LC.DOC < prev    next >
Text File  |  1989-08-01  |  101KB  |  4,282 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.                 Chapter 1
  14.  
  15.                 OVERVIEW
  16.  
  17.  
  18. 1.1  FEATURES
  19.  
  20.  
  21. The LiteComm ToolBox(TM) is a set of powerful routines designed to
  22. provide easy access to the full capabilities of the PC's asynchronous
  23. communications ports. The LiteComm ToolBox provides interrupt-driven,
  24. buffered communications support on COM1 through COM4 simultaneously.
  25. Now you can quickly incorporate sophisticated communications support
  26. in your applications without having in-depth knowledge of how the
  27. hardware functions.
  28.  
  29. The ToolBox was developed as the result of a need to provide just this
  30. type of support in CAD/CAM applications created for a client company.
  31. Each version of the LiteComm ToolBox is heavily integrated with its
  32. respective host compiler.
  33.  
  34. The 'Lite' in LiteComm refers to the high granularity of the product.
  35. A typical, simple application of LiteComm to a problem will add less
  36. than 4.5 kbytes to the program's code, yet provides a highly reliable
  37. base on which to build.
  38.  
  39.  
  40. 1.2  THE SHAREWARE CONCEPT
  41.  
  42.  
  43. Shareware is a "try before you buy" means of software distribution. If
  44. you find a shareware product useful, pay the registration fee, and let
  45. the authors know that you support their efforts.
  46.  
  47. Information Technology is a member of the Association of Shareware
  48. Professionals (ASP).  ASP wants to make sure that the shareware
  49. principle works for you.  If you are unable to resolve a shareware-
  50. related problem with an ASP member by contacting the member directly,
  51. ASP may be able to help.  The ASP Ombudsman can help you resolve a
  52. dispute or problem with an ASP member, but does not provide technical
  53. support for members' products.  Please write to the ASP Ombudsman at
  54. P.O.  Box 5786, Bellevue, WA 98006 or send a Compuserve message via
  55. easyplex to ASP Ombudsman 70007,3536.
  56.  
  57.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  58.             for Microsoft and Turbo C
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.                  Page 2
  120.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  121.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  122.             for Microsoft and Turbo C
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.                   Chapter 2
  133.  
  134.           LICENSE, WARRANTY AND REGISTRATION
  135.  
  136.  
  137. 2.1  LICENSE
  138.  
  139.  
  140. The LiteComm ToolBox, small model library only, is distributed as a
  141. shareware product. To receive all model libraries and/or the source
  142. code for the product, register your copy today. See the registration
  143. form at the end of this manual.  Under the povisions of the license,
  144. you must register the LiteComm ToolBox if you intended to use it in a
  145. commercially distributed application
  146.  
  147. Information Technology, Ltd, grants to registered users a
  148. nonexclusive, perpetual license to the LiteComm ToolBox, subject to
  149. these terms and conditions:
  150.  
  151.    1.    You must treat your copy of the LiteComm ToolBox as you would a
  152.     book.  You may install the LiteComm ToolBox on more than one
  153.     machine, but you may use only one copy at a time.  If you
  154.     desire, site licenses are available at a reduced cost.  You may
  155.     make as many copies of the LiteComm ToolBox as you require for
  156.     the sole purpose of backup.
  157.  
  158.    2.    You may incorporate portions of the LiteComm ToolBox in
  159.     products that you develop without the payment of additional
  160.     royalties or license fees.  We request that you include the
  161.     statement 'Portions Copyright 1987, 88, 89, Information
  162.     Technology, Ltd' in your product's documentation.
  163.  
  164.    3.    You may copy and redistribute the shareware portion of the
  165.     LiteComm ToolBox, commonly known as MCOMM.ARC and TCOMM.ARC,
  166.     but you may not modify in any way, the contents of the
  167.     shareware package.
  168.  
  169.    4.    Information Technology grants to ASP-approved vendors only the
  170.     right to charge a duplication fee, not to exceed $8.00 for
  171.     providing a copy of the shareware version of the product.  No
  172.     other individual or vendor is permitted to charge a fee for
  173.     providing such a copy without the express, written consent of
  174.     Information Technology, Ltd,
  175.  
  176.    5.    You may not redistribute, in any form, the source code for the
  177.     LiteComm ToolBox.  Further, you may not translate the source
  178.     code for the LiteComm ToolBox into any other programming
  179.  
  180.  
  181.  
  182.  
  183.                  Page 3
  184.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  185.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  186.             for Microsoft and Turbo C
  187.  
  188.  
  189.  
  190.     language without the express, written consent of Information
  191.     Technology, Ltd.
  192.  
  193.    6.    Information Technology reserves the right to change the
  194.     LiteComm ToolBox, its documentation and specifications without
  195.     prior notice, and with no obligation to you, the licensee.
  196.  
  197.    7.    You agree that any disputes arising from this license will be
  198.     subject to the laws of the state of Rhode Island.
  199.  
  200.    8.    You agree to hold the developer and distributors of the
  201.     LiteComm ToolBox harmless for any damages, either direct or
  202.     consequential, that might arise from the use of this product,
  203.     even if you inform the developer and distributors in advance of
  204.     the possibility of such damage.
  205.  
  206.    9.    You acknowledge that the LiteComm ToolBox libraries, source
  207.     code, and documentation are licensed material and the
  208.     copyrighted property of Information Technology, Ltd.
  209.  
  210.   10.    By your use of the LiteComm ToolBox in any way, you acknowledge
  211.     that you have read, and understand the terms and conditions of
  212.     this license.
  213.  
  214.  
  215. 2.2  WARRANTY
  216.  
  217.  
  218. The LiteComm ToolBox is distributed as-is and without warranty,
  219. including, but not limited to, the implied warranties of
  220. merchantability and fitness for a particular purpose.
  221.  
  222. Information Technology, Ltd does warrant the distribution media for a
  223. period of 30 days.  During that period, Information Technology, Ltd
  224. will replace the distribution media or provide a refund at its option.
  225.  
  226.  
  227. 2.3  REGISTERING YOUR COPY
  228.  
  229.  
  230. Registration of your copy of the LiteComm ToolBox provides you with
  231. several benefits:
  232.  
  233.    1.    Puts you on our mailing list for low-cost updates,
  234.     enhancements, and alert bulletins when they occur.
  235.  
  236.    2.    Gives you access to telephone support. Sorry, but we cannot
  237.     provide support by telephone to unregistered user's of the
  238.     ToolBox. Unregistered users can leave EMAIL on Compuserve to
  239.     70166,1152; or on GEnie to I.TECH. We will respond to EMAIL on
  240.     an as-available basis.
  241.  
  242.    3.    Helps to further the shareware concept.
  243.  
  244.  
  245.  
  246.  
  247.                  Page 4
  248.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  249.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  250.             for Microsoft and Turbo C
  251.  
  252.  
  253.  
  254. You can order directly from us or from the Public (Software) Library
  255. 1-800-2424-PSL (for orders only. For information call 1-713-665-7017)
  256. or by writing PSL; P.O.Box 35705; Houston, TX 77235-5705.  MC/Visa
  257. Accepted.
  258.  
  259. If you want to order directly from us, print the file REG.FRM and
  260. follow the instructions there.
  261.  
  262.  
  263. 2.4  NOTE
  264.  
  265.  
  266. LiteComm is a package undergoing continuing development.  We are
  267. constantly reviewing the product in an effort to make it smaller,
  268. faster, more reliable, and easier to use.  Since its introduction in
  269. mid 1987, we have made significant changes to the LiteComm kernel, the
  270. 'heart' of the ToolBox to improve efficiency and reliability.  We have
  271. also delivered to registered users protocol engines, LXM - the XMODEM
  272. engine, which supports Xmodem and Xmodem-1K; and LWXM - the Windowed
  273. Xmode,m engine.  We also provide a version of the Compuserve QUICKB
  274. protocol, specially adapted for use with the LiteComm ToolBox.
  275.  
  276. Implementations of other protocol engines are under development. We
  277. plan to follow these with similar engines for YModem, ZModem, SeaLink,
  278. and Telink. These engines, as they are released, will only be made
  279. available to registered ToolBox users. The small model library, as
  280. enhanced but without the protocol engines, will continue to be offered
  281. as a shareware product.
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.                  Page 5
  312.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  313.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  314.             for Microsoft and Turbo C
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.                  Page 6
  376.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  377.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  378.             for Microsoft and Turbo C
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.                   Chapter 3
  389.  
  390.             Serial Port Fundamentals
  391.  
  392.  
  393. 3.1  The 8250 UART family
  394.  
  395.  
  396. This portion of the manual provides you with some details about the
  397. working of the 8250 (and related) UART'S, the basic component of your
  398. system's serial port.  Some close compatibles use enhanced versions of
  399. this chip, such as the Intel 16450.  LiteComm is known to work
  400. successfully with such devices.  If you have questions about the kind
  401. of serial port you are using, refer to the manufacturer's
  402. documentation.  If your serial port does not use an 8250 or similar
  403. chip, LiteComm will not function.
  404.  
  405.  
  406. 3.2  Purpose of the port
  407.  
  408.  
  409. The purpose of the serial port is to convert information from the form
  410. in which it is used within your system, to a form that can be easily
  411. used outside your system.  Modern computers, by design, are parallel
  412. in nature.  By this we mean that information travels through the
  413. computer's circuitry as whole units or as multiples of whole units. In
  414. the IBM PC and related systems, information travels as bytes (8 bits
  415. at a time), as words (16 bits at a time), or, on 80386 based systems,
  416. as double words (32 bits at a time).
  417.  
  418. Within the computer, such arrangements are convenient and fast. But
  419. when the computer must transfer information to an external device, the
  420. problem of data path width is introduced.  To provide a true, parallel
  421. path between the computer and external devices, there would have to
  422. be, at a minimum, enough data lines or circuits between the two to
  423. satisfy the data path.  For most modern computer systems, this would
  424. mean a minimum of 8 data lines, not counting any additional control
  425. information that might also be required.  For certain newer systems,
  426. the requirement might be for as many as 32 data lines.  In effect, it
  427. might be necessary to have several different versions of a device,
  428. dependent upon the data path width of the computer to which it is
  429. connected.
  430.  
  431. The purpose of a serial port is to convert the information from its
  432. internal, parallel form, to a more common, external form and back
  433. again.  By using such an approach, we simplify the interconnection of
  434. devices, reducing information to its lowest common denominator, the
  435. bit. And it allows us to transfer information 1 bit at a time, using a
  436.  
  437.  
  438.  
  439.                  Page 7
  440.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  441.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  442.             for Microsoft and Turbo C
  443.  
  444.  
  445.  
  446. single data path, between devices. The real beauty of this approach is
  447. that, by 'agreeing' on how this external form appears, each device can
  448. hide the details of how it works, and still accomplish the required
  449. task.
  450.  
  451.  
  452. 3.3  Internal Details
  453.  
  454.  
  455. In this section we discuss the fundamental working of serial ports as
  456. they are implemented of the IBM PC and close compatible systems.  It
  457. is not essential that you understand this material thoroughly to be
  458. successful with LiteComm. However, it may help to answer some of the
  459. more important questions that may arise as you proceed with your
  460. development.
  461.  
  462. 3.3.1  The Interrupt Connection
  463.  
  464. The PC is an interrupt driven system. This is a sophisticated way of
  465. saying that the PC can 'pay attention' to a number of internal devices
  466. without the necessity of having to check on them periodically.
  467.  
  468. When we describe interrupts to clients, we use the school room as a
  469. metaphor. Think of a teacher lecturing to a group of students during a
  470. class.  The teacher knows that, on occasion, one or more students may
  471. not understand the material that is being presented.  So the teacher
  472. has the choice of either asking each student periodically if they
  473. understand or permitting the students to raise a hand to ask a
  474. question.  As you can imagine, stopping the class to 'poll' each
  475. student will waste valuable time, particularly if no one wants to ask
  476. a question. Not only is it wasteful of time, but the last student
  477. polled may have forgotten the question he or she wanted to ask by the
  478. time the teacher gets to him.  If the teacher permits students to
  479. 'interrupt' his lecture by raising a hand, much less time is wasted,
  480. but the teacher has to be careful to identify each raised hand by name
  481. and answer the question quickly and accurately, lest some student
  482. forget his question or looses interest altogether.
  483.  
  484. The internal working of most modern computers is identical to the
  485. teacher that permits hand raising.  The computer focuses on the task
  486. at hand, stopping only to identify and pay attention to devices when
  487. they signal that they require this attention.  So much for the
  488. hardware end of things.  The PC has this same capability.  But at
  489. least some of the work that has to be done requires software in a
  490. general purpose computer, otherwise the computer wouldn't be general
  491. purpose.
  492.  
  493. The serial port on the PC is no less capable of asking for attention
  494. from the computer, at least from the standpoint of hardware.  But, for
  495. whatever the reason, MS-DOS and PC-DOS do not provide the needed
  496. software to exploit the full capabilities of the serial port. OS/2
  497. does provide such support, we are told, but, at least for the
  498. foreseeable future, its an MS-DOS world. On PC's and true compatibles,
  499. the only support for the serial port that is provided is through the
  500.  
  501.  
  502.  
  503.                  Page 8
  504.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  505.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  506.             for Microsoft and Turbo C
  507.  
  508.  
  509.  
  510. system's ROM BIOS.  And that support is only for the polled mode of
  511. operation.
  512.  
  513. The method by which 80x86 family systems, of which the PC is a part,
  514. is elegant in its simplicity.  When a device needs the attention of
  515. the system, its asserts a control signal and identifies itself with a
  516. number ranging from 0 to 255. On the basic PC, the numbers used
  517. actually range from 8 through 15 decimal.  The identification is
  518. translated to a memory location by multiplying the identification by
  519. 4, and the system simulates a special form of a call to the routine
  520. whose address is stored at that location.  Since it is impossible to
  521. predict when a device will require attention, the full address of the
  522. routine is stored, both segment and offset, hence the 4.
  523.  
  524. Once the routine, called the Interrupt Service Routine or ISR is
  525. invoked, it has a duty to save the state of the system when the
  526. interrupt occurred, take care of the interrupt as quickly as possible,
  527. and return control to the interrupted process.  But it must also be
  528. aware that, while it is doing its work, other, more important devices
  529. may require attention, too.
  530.  
  531. One such device that is likely to require attention is the system
  532. clock which ticks roughly 18 times per second.  In part, the PC makes
  533. provision for this by prioritizing the interrupt scheme.  The ISR must
  534. allow for this by re- enabling the interrupt control system as rapidly
  535. as it is practical to do so.  The PC's interrupt structure, if left
  536. undisturbed, will prevent interrupts of the same or lower priority
  537. from occurring. To help your organize your thoughts, the standard
  538. identification for the first two serial ports on the system are 12
  539. (0C) and 11 (0B) for ports 1 and 2 respectively.
  540.  
  541. As you can see, dealing with the PC's interrupt structure is not for
  542. the faint of heart.  It requires a significant amount of knowledge,
  543. and close attention to detail.  With LiteComm, these details have
  544. already been taken care of for you.  You are free to focus on your
  545. application, treating the serial port in much the same way that you
  546. would any DOS file.
  547.  
  548. 3.3.2  The Programmable Port Registers
  549.  
  550. The 8250 port, and its close relatives, are fully programmable.  You
  551. are fortunate that LiteComm has already taken care of the intricacies
  552. of this programming. But some additional information about each of the
  553. registers used in the serial port may be of use when you are
  554. attempting to communicate with an external device. For the sake of
  555. this discussion, we use the basic register numbers, although the
  556. register number that is employed in programming is actually the
  557. register number referenced below used as an offset to a base port
  558. number. In the case of COM1 (port 1), this base is 3F8(hexadecimal).
  559.  
  560.  
  561.  
  562.  
  563.  
  564.  
  565.  
  566.  
  567.                  Page 9
  568.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  569.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  570.             for Microsoft and Turbo C
  571.  
  572.  
  573.  
  574. 3.3.2.1  register 0 - transmit/receive
  575.  
  576. In normal operation, individual characters are read from register 0
  577. when the become available, and are written to register 0 when the
  578. transmitter portion of the 8250 is ready to accept a character.
  579.  
  580. 3.3.2.2  register 0 - baud rate selection
  581.  
  582. During initialization, register 0 is used as part of the mechanism
  583. that sets baud rate.  During this process, register 0 and its
  584. companion register 1 are used to specify the baud rate divisor (not
  585. the actual baud rate). The baud rate divisor is a value which, when
  586. divided into a given, preset constant, yields the desired baud rate.
  587. To use registers 0 and 1 to set the baud rate, access to this mode
  588. must be first enabled by writing a value of 80H to register 3, the
  589. line control register.  Once access is enabled, the least significant
  590. byte (LSB) of the divisor is written to register 0; the most
  591. significant byte is written to register 1.  Access to the normal modes
  592. of registers 0 and 1 are re- enabled by writing any value less than
  593. 80H to the line control register.  Of course, only certain values less
  594. than 80H would be meaningful (see the line control register
  595. description below).
  596.  
  597. 3.3.2.3  register 1 - interrupt enable
  598.  
  599. Values written to register 1 control which conditions will cause the
  600. 8250 to interrupt the system. There are four possible conditions that
  601. can cause interrupts:
  602.  
  603.    1.    A character has been received (RDI)
  604.  
  605.    2.    The transmitter is ready to send a character (TDI)
  606.  
  607.    3.    An error or BREAK signal has been detected (ERI)
  608.  
  609.    4.    A modem status  signal has changed (MSI)
  610.  
  611. The designations, in parentheses, are for our purposes only. They are
  612. not 'standard' designations. To enable a particular type of interrupt,
  613. you must set the corresponding bit in a byte to a 1, then write the
  614. byte to register 1.  To reset (ignore) the condition, set the
  615. corresponding bit to 0.  The diagram that follows shows the bit
  616. positions the correspond to the various conditions described above.
  617.  
  618. +------+------+------+------+------+------+------+------+
  619. |      |      |      |      |       |      |     |    |
  620. |  N/A |  N/A |  N/A |  N/A |Modem |Error/| Xmit | Recv |
  621. |      |      |      |      |Status|Break |Ready | Char |
  622. +------+------+------+------+------+------+------+------+
  623.     7      6     5    4    3      2      1      0
  624.         Figure 3.1: Register 1 Bit Definitions
  625.  
  626.  
  627.  
  628.  
  629.  
  630.  
  631.                  Page 10
  632.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  633.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  634.             for Microsoft and Turbo C
  635.  
  636.  
  637.  
  638. 3.3.2.4  register 1 - baud rate selection
  639.  
  640. See the description under register 0, baud rate selection.
  641.  
  642. 3.3.2.5  register 2 - interrupt identification
  643.  
  644. Register 2, in normal operation, acts as a companion to register 1.
  645. Register 1 determines the conditions that can cause an interrupt.
  646. Register 2 is used to determine which condition actually caused the
  647. interrupt, when more than one condition has been enabled.  Only least
  648. significant 3 bits of the register are actually employed.  See the
  649. diagram of register 2 below.
  650.  
  651. +------+------+------+------+------+------+------+------+
  652. |      |      |      |      |       |      |     |    |
  653. |  N/A |  N/A |  N/A |  N/A |  N/A |  see |below |  Int |
  654. |      |      |      |      |       |      |     | pend |
  655. +------+------+------+------+------+------+------+------+
  656.     7       6      5     4    3      2      1      0
  657.         Figure 3.2: Register 2 Bit Definitions
  658.  
  659. Since it is possible, even likely, that more than one condition may
  660. occur at the same time, bit 0 is used to determine whether all
  661. conditions that currently exist have been handled.  When bit 0 has a
  662. value of 0 (yes zero), there are conditions waiting to be handled.
  663. When bit 0 has a value of 1, all outstanding conditions have been
  664. handled.  Bits 2 and 1 taken together identify the actual cause of the
  665. interrupt.
  666.  
  667. Again, because of the multiple conditions which may occur, the 8250
  668. presents the conditions in a prioritized order.  When bits 2 and 1
  669. have a value of 3 (the most important), an ERI condition has been
  670. identified. The actual error is determined by reading the line status
  671. register(register 5). Reading this register also clears the condition.
  672.  
  673. When a value of 2 is present, an RDI condition has occurred, and a
  674. character should be read. from port 0. If the character is not read
  675. quickly enough, a data overrun error may occur, indicating that a
  676. character was lost.
  677.  
  678. When bits 2 and 1 have a value of 1, a TDI condition has occurred and
  679. a character may be written to register 0.
  680.  
  681. A value of zero in bits 2 and 1(least important) indicates that one or
  682. more of the modem status lines (so called) have changed. The condition
  683. is cleared by reading the contents of the modem status register,
  684. register 6.
  685.  
  686. 3.3.2.6  register 3 - line control
  687.  
  688. The line control register provides the means for setting those values
  689. that affect the way in which the serial port appears to the outside
  690. world.  It is through this register that character length, parity, and
  691. other significant values are established. Indirectly, register 3 also
  692.  
  693.  
  694.  
  695.                  Page 11
  696.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  697.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  698.             for Microsoft and Turbo C
  699.  
  700.  
  701.  
  702. plays a role in setting the speed (baud rate) of the port. (See the
  703. description of registers 0 and 1 above.)
  704.  
  705. +------+------+------+------+------+------+------+------+
  706. | Baud |      |      |      |       |      |     |    |
  707. |  Div | Send |Force |Parity|Enable| Stop |  Character  |
  708. |Enable|Break |Parity| Type |Parity| Bits |    Length    |
  709. +------+------+------+------+------+------+------+------+
  710.     7      6     5    4    3      2      1      0
  711.         Figure 3.3: Register 3 Bit Definitions
  712.  
  713. 3.3.2.7  register 4 - modem control
  714.  
  715. The modem control register permits control of the two modem- related
  716. signals that the serial port generates as an output.  The signals are
  717. RTS and DTR.
  718.  
  719. These two signals are called 'handshaking' signals, since they, in
  720. part, help a connected device determine the state of the connection.
  721. You should be aware that although these signals were originally
  722. designated to be used in a specific fashion, manufacturers of specific
  723. devices have used them to meet their own needs. Your success or
  724. failure in dealing with any specific device may depend, in part, on
  725. your understanding of how the device's manufacturer uses these
  726. signals. LiteComm provides you the means for manipulating these
  727. signals in a variety of ways.
  728.  
  729. You will notice in the register 4 diagram, below that some additional
  730. positions are identified.
  731.  
  732. +------+------+------+------+------+------+------+------+
  733. |      |      |      |      |       |      |     |    |
  734. |  N/A |  N/A |  N/A |Enable| OUT2 |  N/A |Enable|Enable|
  735. |      |      |      |Loopbk|(reqd)|      | RTS  | DTR  |
  736. +------+------+------+------+------+------+------+------+
  737.     7      6      5    4      3       2      1      0
  738.         Figure 3.4: Register 4 Bit Definitions
  739.  
  740. LiteComm controls all of these additional positions for your benefit.
  741. Only one deserves mention, the position labeled OUT2.  It is necessary
  742. for this position to have a value of 1 for the serial port to function
  743. as an interrupting device. Since LiteComm relies on interrupts to
  744. perform it's job, it insures that this position is always set
  745. correctly.
  746.  
  747. 3.3.2.8  register 5 - line status
  748.  
  749. The line status register is read normally when an ERI condition
  750. occurs.  Each bit of the character returned when the port is read has
  751. significance, as shown in the accompanying diagram. Using the
  752. appropriate functions in LiteComm, you can interrogate the value in
  753. this register, and test for the various conditions using the LiteComm-
  754. provided definitions. Note that, due to the special nature of the
  755. BREAK signal, LiteComm treats this one condition as a separate entity.
  756.  
  757.  
  758.  
  759.                  Page 12
  760.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  761.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  762.             for Microsoft and Turbo C
  763.  
  764.  
  765.  
  766. +------+------+------+------+------+------+------+------+
  767. |      |Shift | Hold |      |       |      |     |    |
  768. | Time |Reg   | Reg  | Recd |Frame |Parity| Data | Char |
  769. | Out  |Empty |Empty |Break |Error |Error |OvrRun| Recd |
  770. +------+------+------+------+------+------+------+------+
  771.     7      6     5    4      3       2      1      0
  772.         Figure 3.5: Register 5 Bit Definitions
  773.  
  774. 3.3.2.9  register 6 - modem status
  775.  
  776. Just as the serial port can generate certain 'handshaking' signals, it
  777. can also read, and report on the status of similar signals that are
  778. generated by an external device.  In their original form, these
  779. signals had special significance when a terminal was connected to a
  780. modem. We refer you to our comments, above, about present day use of
  781. the handshaking signals.
  782.  
  783. One special note is appropriate here.  The modem status register
  784. actually provides two types of information.  The most significant 4
  785. bits (see the diagram) show the current state of the 4 covered
  786. signals.  The least significant 4 bits indicate which, if any, of the
  787. signals have changed state (from zero to one, or vice-versa), since
  788. the last time the register was interrogated.  LiteComm updates its
  789. internal tables with this value in real-time, and reports the results
  790. when asked to do so.  You can test the signals individually or in
  791. combination using the LiteComm-provided definitions.
  792.  
  793. +------+------+------+------+------+------+------+------+
  794. |  DCD |  RI  |  DSR |  CTS |       |      |     |    |
  795. | carr | ring |data  |clr to|DELTA |DELTA |DELTA |DELTA |
  796. |detect|indic |set rd| send | DCD  |  RI  | DSR  | CTS  |
  797. +------+------+------+------+------+------+------+------+
  798.     7       6      5     4     3       2      1      0
  799.  
  800.  
  801. 3.4  The LiteComm Connection
  802.  
  803.  
  804.         Figure 3.6: Register 6 Bit Definitions
  805.  
  806. In the design of LiteComm, we have purposely 'hidden' many of the
  807. underlying details we presented above. In many cases, you will have
  808. little use for this additional information. This is particularly true
  809. of most of the applications with which come into contact.  In fact, in
  810. the majority of applications, you will probably open the port or
  811. ports, set the necessary parameters and modem control signals, and do
  812. nothing more than read and write characters using one or more of the
  813. LiteComm functions.  The beauty of LiteComm's design is that its high
  814. degree of granularity doesn't force you to pay the price of dragging
  815. along functions that you are not using.
  816.  
  817. The information that we presented above will help you when  it is
  818. necessary to communicate with a device that requires special
  819. handshaking considerations, such as a cash drawer.  You may also need
  820.  
  821.  
  822.  
  823.                  Page 13
  824.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  825.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  826.             for Microsoft and Turbo C
  827.  
  828.  
  829.  
  830. some of the information we presented if you intend to use serial ports
  831. beyond COM2 (serial port 2).
  832.  
  833. Finally, by presenting the information that we have supplied, we hope
  834. to gain a more informed user.  Communications programming is not the
  835. black art that some would have you believe, although it can easily
  836. seem that way at times.  Of all of the calls we receive who need
  837. questions answered, more than 75 per cent could have been answered by
  838. the caller himself with a more thorough understanding of the
  839. underlying concepts and rules.
  840.  
  841.  
  842. 3.5  ToolBox NOTES AND WARNINGS
  843.  
  844.  
  845. Before you can send or receive information on a serial port using the
  846. ToolBox, you must use the open function to enable the line. This
  847. function initializes the 8250 UART with the correct parameters, and
  848. introduces the UART into the interrupt structure of the PC. The
  849. ToolBox will detect, and report, any errors that you may make in
  850. selecting the port or specifying the initial parameters. The ToolBox
  851. will not detect an attempt to open a nonexistent serial port.
  852.  
  853. The ToolBox interfaces directly with the interrupt structure of the
  854. PC. It is critical before exiting a program that has opened a serial
  855. port that the serial port is closed with the close function. Since it
  856. is possible for a program to terminate abnormally, the open function
  857. installs an exit routine that will automatically close any open ports.
  858. Good programming practice demands, however, the your program should
  859. close the ports explicitly.  By so doing, you may avoid problems in
  860. the future if we find it necessary to remove the auto-close
  861. functionality. Further, the auto-close functionality drops all modem
  862. handshaking signals absolutely, while an explicit close can decide
  863. whether or not to drop these signals. If you are unaware of exit
  864. functions, check your compiler's documentation for the atexit()
  865. function for a complete explanation. And review the description of the
  866. comm_close() function, as well.
  867.  
  868. Failure of the open function can be the result of either improper
  869. parameters to the open function, or insufficient memory available to
  870. allocate the requested buffers and related control structures for the
  871. port, or both. Memory for the transmit and receive buffers as well as
  872. the port control block are allocated from free memory. It is your
  873. responsibility to insure that adequate memory is available for this
  874. purpose.  In general, this requires no particular action on your part,
  875. but if you use LiteComm in combination with other packages, the other
  876. packages may place specific restrictions on your use of free memory.
  877.  
  878. The 8250 serial chip and its descendants will not transmit information
  879. until, at a minimum, the DTR (Data Terminal Ready) signal is asserted.
  880. The ToolBox will, at your option, assert both the DTR and RTS signals
  881. when you open the port.  If you do not select this option  you must
  882. use the lc_setmdm function to assert (raise) this signal.  In
  883. addition, some modems and other devices may require you to assert the
  884.  
  885.  
  886.  
  887.                  Page 14
  888.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  889.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  890.             for Microsoft and Turbo C
  891.  
  892.  
  893.  
  894. RTS (Request To Send) signal before they will respond to data.  The
  895. use of this, and other handshaking signals is HIGHLY hardware-
  896. dependant.  The ToolBox provides all the functionality necessary for
  897. you to implement virtually any handshaking scheme that might be
  898. required.
  899.  
  900. Due to the use of all available interrupt modes of the 8250, one user
  901. has discovered an unusual set of circumstances that can be
  902. troublesome.  If the 8250 chip detects an error condition, such as a
  903. parity error, framing error, or data overrun error, it causes an
  904. interrupt to which the ToolBox will respond.  If these errors occur
  905. frequently enough, the ToolBox code will spend too much time handling
  906. the errors, and lose characters as a result, causing additional
  907. errors.  If you encounter a situation in which your application
  908. appears to behave erratically, especially at higher speeds,
  909. investigate the following table.
  910.  
  911.          Table 3.1: Possible Error Conditions
  912.  
  913.     -    Is the cabling to the other device sound and solidly connected.
  914.  
  915.     -    Are any of the signals in the cable 'floating' or are they all
  916.     properly terminated.
  917.  
  918.     -    Is the other device known to be functioning properly. We have
  919.     encountered situations in which a serial port on some devices
  920.     tend to be sloppy in terms of voltage levels, bit timings, and
  921.     similar problems.  Any or all of these situations can cause the
  922.     erratic operation to which we referred.
  923.  
  924. Unless you are very familiar with the interrupt structure of the PC,
  925. do not attempt to manipulate the interrupt enable flag outside of the
  926. ToolBox. The ToolBox sets and clears the interrupt enable flag at
  927. appropriate times and assumes that it has sole control over the flag.
  928.  
  929. Unless otherwise specified, all library functions have been compiled
  930. with byte structure alignment. This alignment is made necessary by the
  931. way in which the interrupt handler was developed in assembly language.
  932.  
  933.  
  934.  
  935.  
  936.  
  937.  
  938.  
  939.  
  940.  
  941.  
  942.  
  943.  
  944.  
  945.  
  946.  
  947.  
  948.  
  949.  
  950.  
  951.                  Page 15
  952.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  953.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  954.             for Microsoft and Turbo C
  955.  
  956.  
  957.  
  958.  
  959.  
  960.  
  961.  
  962.  
  963.  
  964.  
  965.  
  966.  
  967.  
  968.  
  969.  
  970.  
  971.  
  972.  
  973.  
  974.  
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981.  
  982.  
  983.  
  984.  
  985.  
  986.  
  987.  
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.  
  995.  
  996.  
  997.  
  998.  
  999.  
  1000.  
  1001.  
  1002.  
  1003.  
  1004.  
  1005.  
  1006.  
  1007.  
  1008.  
  1009.  
  1010.  
  1011.  
  1012.  
  1013.  
  1014.  
  1015.                  Page 16
  1016.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  1017.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  1018.             for Microsoft and Turbo C
  1019.  
  1020.  
  1021.  
  1022.  
  1023.  
  1024.  
  1025.  
  1026.  
  1027.  
  1028.                   Chapter 4
  1029.  
  1030.                 RECENT CHANGES
  1031.  
  1032.  
  1033. 4.1  NEW IN VERSION 5.00
  1034.  
  1035.  
  1036. In version 5.0, we have improved on the assembly language interrupt
  1037. handlers, further tightening the code.  In addition, significant
  1038. changes have been made in the supporting functions to tighten the
  1039. code.  The result is smaller applications, in most cases, able to
  1040. operate at higher baud rates than before.
  1041.  
  1042. We have also removed support for the lc_insclock and lc_clrclock
  1043. functions.  The protocol engines now rely on event timers, introduced
  1044. in version 4.0 of LiteComm.
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.  
  1061.  
  1062.  
  1063.  
  1064.  
  1065.  
  1066.  
  1067.  
  1068.  
  1069.  
  1070.  
  1071.  
  1072.  
  1073.  
  1074.  
  1075.  
  1076.  
  1077.  
  1078.  
  1079.                  Page 17
  1080.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  1081.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  1082.             for Microsoft and Turbo C
  1083.  
  1084.  
  1085.  
  1086.  
  1087.  
  1088.  
  1089.  
  1090.  
  1091.  
  1092.  
  1093.  
  1094.  
  1095.  
  1096.  
  1097.  
  1098.  
  1099.  
  1100.  
  1101.  
  1102.  
  1103.  
  1104.  
  1105.  
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112.  
  1113.  
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.  
  1127.  
  1128.  
  1129.  
  1130.  
  1131.  
  1132.  
  1133.  
  1134.  
  1135.  
  1136.  
  1137.  
  1138.  
  1139.  
  1140.  
  1141.  
  1142.  
  1143.                  Page 18
  1144.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  1145.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  1146.             for Microsoft and Turbo C
  1147.  
  1148.  
  1149.  
  1150.  
  1151.  
  1152.  
  1153.  
  1154.  
  1155.  
  1156.                   Chapter 5
  1157.  
  1158.                  BEYOND COM2
  1159.  
  1160.  
  1161. 5.1  THE ToolBox METHODOLOGY
  1162.  
  1163.  
  1164. In the design of the original PC, and in subsequent variations such as
  1165. the PC/AT, there were only provision for two serial ports. Many
  1166. manufacturers of add-in products, both serial ports and internal
  1167. modems have added the capability to support 1 or more additional ports
  1168. beyond the COM2 limit. Generally, this can cause problems in the PC
  1169. since there is no room in the interrupt request scheme for additional
  1170. levels of interrupts, and there are no designated interrupt vector for
  1171. other additional ports.
  1172.  
  1173. The ToolBox approach to resolving these issues is to permit the
  1174. programmer a degree of control over the parameters that govern the
  1175. interrupt mechanism for COM3 and COM4. Specifically, these parameters
  1176. are:
  1177.  
  1178.    1.    The interrupt request (IRQ) bit that is used to mask the 8259
  1179.     interrupt controller.
  1180.  
  1181.    2.    The interrupt vector number (not address) to which the port is
  1182.     attached.
  1183.  
  1184.    3.    The base i/o register for the port itself. Of course, it is
  1185.     assumed that the port is based upon the 8250 UART or compatible
  1186.     device.  Again, the LiteComm ToolBox will not function with
  1187.     non-8250 type devices.
  1188.  
  1189. Before you attempt to use COM3 and/or COM4, you must determine from
  1190. the port's documentation, the appropriate values for these three
  1191. parameters. As distributed, the ToolBox assumes the following:
  1192.  
  1193.  
  1194.           Table 5.1: COM3 and COM4 Default Settings
  1195.  
  1196.                 COM3        COM4
  1197.  
  1198. IRQ Bit                4        3
  1199. Vector #            0Ch        0Bh
  1200. Base Reg            3E8h        2E8h
  1201.  
  1202. You may change any or all of these values by using the _portchg
  1203. function described below, but only before you open the port with
  1204.  
  1205.  
  1206.  
  1207.                  Page 19
  1208.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  1209.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  1210.             for Microsoft and Turbo C
  1211.  
  1212.  
  1213.  
  1214. comm_opn. Once the port has been opened, _portchg is ineffective, and
  1215. _portchg will not work on COM1 or COM2.
  1216.  
  1217. At present, LiteComm is not compatible with multiport boards such as
  1218. the Digiboard.  The structure of these boards generally require
  1219. additional programming to be used effectively.  If you want to use
  1220. such a board with LiteComm, please contact us directly for information
  1221. on custom modifications to LiteComm.  We have performed such
  1222. modifications for other LiteComm users.
  1223.  
  1224.  
  1225. 5.2  CAUTIONS
  1226.  
  1227.  
  1228. There is an intimate relationship between the IRQ setting and the
  1229. interrupt vector to which it relates. In the PC, this relationship is
  1230. controlled, in part, by the 8259 interrupt controller that is set
  1231. during BIOS initialization.
  1232.  
  1233. In brief, the BIOS settings for the PC (and most close compatibles)
  1234. establish IRQ0 as being vector number 08h, and subsequent IRQ levels
  1235. at increasing vector numbers. These vector numbers (or types in INTEL
  1236. terms) act as a cpu- directed call table to locations in the lowest 1K
  1237. of system memory. We can alter how the system responds to a given
  1238. interrupt by replacing or changing the values in the associated vector
  1239. position to point to a routine which we supply.
  1240.  
  1241. Judging from the questions asked by some users of LiteComm, there is
  1242. evidently some misunderstanding about using ports beyond COM2, and how
  1243. this all relates to your hardware. Before you can successfully use
  1244. COM3 or COM4, you must consider the following:
  1245.  
  1246.    1.    Does the hardware permit a change to the base port and/or the
  1247.     interrupt vector to which the port responds.  Some expansion
  1248.     cards will support changing one and not the other, giving rise
  1249.     to potential hardware conflicts and lost data.
  1250.  
  1251.    2.    Does the hardware permit  reassignment of the IRQ priority.
  1252.     Some expansion cards permit you to alter the IRQ priority, some
  1253.     won't. Suffice it to say from the previous discussion the any
  1254.     change to the IRQ priority must allow a corresponding change to
  1255.     the interrupt vector number. Without this capability,
  1256.     reprogramming of the 8259 chip would be required.
  1257.  
  1258.    3.    In fact, many add-on cards permit this dual change simply by
  1259.     making a single switch or jumper setting. Unfortunately, the
  1260.     documentation for these cards  generally assume that you are
  1261.     aware of the dual nature of the IRQ vector relationship, and
  1262.     may leave you with the impression that you are changing one and
  1263.     not the other. In most circumstances, this is not the case.
  1264.  
  1265. The point to all of this is that LiteComm can only provide as much
  1266. support as the hardware permits, or is capable of responding to. If
  1267. you wish to use other than the default base port, interrupt vector, or
  1268.  
  1269.  
  1270.  
  1271.                  Page 20
  1272.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  1273.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  1274.             for Microsoft and Turbo C
  1275.  
  1276.  
  1277.  
  1278. irq priority for COM3 or COM4, then your expansion card must be
  1279. capable of supporting the new values; in other words, these values are
  1280. all hardware-provided, and are recognized by the LiteComm software. If
  1281. your hardware does not permit changing a value, LiteComm cannot
  1282. improve the situation.
  1283.  
  1284. We should, at this point, add one final caution about how interrupt
  1285. priorities function, and their relationship to the irq bit the you may
  1286. select. The standard PC permits 8 interrupt priority levels, with the
  1287. programmable timer having the highest priority, and the parallel
  1288. printer port having the lowest priority. When an interrupt occurs, the
  1289. interrupt controller (8259 chip) masks out all other interrupts from
  1290. the priority of the interrupting device and all lower priority
  1291. devices.
  1292.  
  1293. As an aid to making COM3 and COM4 "fit", LiteComm supports interrupt
  1294. chaining for the COM3 and COM4 ports. If you use COM3 or COM4, when an
  1295. interrupt occurs, the kernel will attempt to determine if the
  1296. interrupt was caused by the supported port or from some other source.
  1297.  
  1298. If the kernel determines that the supported port did not cause the
  1299. interrupt, an automatic chain to the original interrupt handler for
  1300. that interrupt level (IRQ level) will take place, allowing you to
  1301. "patch in" or share the available interrupt vectors.
  1302.  
  1303. If you intend to use other than the library-provided defaults, be sure
  1304. that you understand the interrupt mechanism. The use of the automatic
  1305. chaining described above can be particularly troublesome under some
  1306. circumstances, resulting in loss of interrupts and, potentially, a
  1307. system crash.
  1308.  
  1309. DO NOT attempt to mix the ToolBox functions with other seemingly-
  1310. related functions (such as the serial port BIOS calls provided in both
  1311. Turbo and Microsoft C).  At least two users have attempted to only use
  1312. the receive portions of LiteComm, while resorting to the BIOS
  1313. functions to send characters or adjust port parameters such as baud
  1314. rate. The results, at best, have been failure of the user's
  1315. application to function, and, at worst, total system lockup.  This mix
  1316. of functions is NOT supported and must not be used.  If you attempt
  1317. such a mix, we cannot help you.
  1318.  
  1319. If you chose to 'share' the interrupt vectors for COM1 or COM2, you
  1320. must be certain to open COM1 (COM2) last.  The interrupt chaining
  1321. mechanism only works with COM3 and COM4.  Failure to follow this
  1322. caution will result in a total loss of function of COM3 (COM4).  In
  1323. addition, the ports should be opened in ascending order of the planned
  1324. baud rate, i.e. the slower port should be opened first, the faster
  1325. port should be opened last.  Whenever possible or practical, you will
  1326. obtain best results by using the same baud rate on both ports.
  1327.  
  1328. One final caution is in order.  One or two users have attempted to
  1329. trace through the interrupts as they occur using debuggers.  This is a
  1330. risky proposition at best since most debuggers work by tapping into,
  1331. and disturbing, the interrupt mechanism.  If you feel you must use a
  1332.  
  1333.  
  1334.  
  1335.                  Page 21
  1336.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  1337.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  1338.             for Microsoft and Turbo C
  1339.  
  1340.  
  1341.  
  1342. debugger, try to stay away from the kernel routines of LiteComm, or
  1343. use a hardware-based debugger such as Periscope.
  1344.  
  1345.  
  1346.  
  1347.  
  1348.  
  1349.  
  1350.  
  1351.  
  1352.  
  1353.  
  1354.  
  1355.  
  1356.  
  1357.  
  1358.  
  1359.  
  1360.  
  1361.  
  1362.  
  1363.  
  1364.  
  1365.  
  1366.  
  1367.  
  1368.  
  1369.  
  1370.  
  1371.  
  1372.  
  1373.  
  1374.  
  1375.  
  1376.  
  1377.  
  1378.  
  1379.  
  1380.  
  1381.  
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.  
  1391.  
  1392.  
  1393.  
  1394.  
  1395.  
  1396.  
  1397.  
  1398.  
  1399.                  Page 22
  1400.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  1401.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  1402.             for Microsoft and Turbo C
  1403.  
  1404.  
  1405.  
  1406.  
  1407.  
  1408.  
  1409.  
  1410.  
  1411.  
  1412.                   Chapter 6
  1413.  
  1414.                PACKAGE CONTENTS
  1415.  
  1416.  
  1417. Your distribution diskette contains several files that are important
  1418. to you. All diskettes, at a minimum, include the following files in
  1419. the diskette's root directory:
  1420.  
  1421.           Table 6.1: Basic Diskette Contents
  1422.  
  1423. READ.ME            LATEST LITECOMM INFORMATION
  1424.  
  1425. TCOMM.ARC        SHAREWARE VERSION - TURBO C
  1426.  
  1427. - OR -
  1428.  
  1429. MCOMM.ARC        SHAREWARE VERSION - MICROSOFT
  1430.  
  1431. TCLIB.ARC        LIBRARIES, TURBO C
  1432.  
  1433. - OR -
  1434.  
  1435. MSCLIB.ARC        LIBRARIES, MICROSOFT
  1436.  
  1437. The diskette contains a sub directory called SOURCE.  The SOURCE
  1438. directory contains 2 source code archives, as well as compiler
  1439. specific archives, to help you build or rebuild the libraries for
  1440. either of the supported compilers.
  1441.  
  1442.  
  1443.            Table 6.2: Optional Source Code
  1444.  
  1445. LITECOMM SOURCE CODE        LCSRC.ARC
  1446.  
  1447. XMODEM ENGINE SOURCE CODE    LXMSRC.ARC
  1448. COMPILER SPECIFIC FILES        MSC.ARC
  1449.                 TURBOC.ARC
  1450.  
  1451.  
  1452. 6.1  COMPILER-SPECIFIC INSTRUCTIONS
  1453.  
  1454.  
  1455. 6.1.1  INSTALLING THE TURBO C VERSION
  1456.  
  1457. In the following discussion, we assume that your regular Turbo header
  1458. files are contained in a directory called \TC\INCLUDE, and that your
  1459.  
  1460.  
  1461.  
  1462.  
  1463.                  Page 23
  1464.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  1465.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  1466.             for Microsoft and Turbo C
  1467.  
  1468.  
  1469.  
  1470. Turbo libraries are in a directory called \TC\LIB, as recommended by
  1471. Borland.
  1472.  
  1473. To install the header files used with LiteComm, perform the following
  1474. steps:
  1475.  
  1476.     o    CD \TC\INCLUDE
  1477.  
  1478.     o    ARC E A:TCOMM *.H
  1479.  
  1480.     o    ARC E A:TCLIB *.H
  1481.  
  1482. To install the library files, perform the following steps:
  1483.  
  1484.     o    CD \TC\LIB
  1485.  
  1486.     o    ARC E A:TCLIB *.LIB
  1487.  
  1488. If you are installing only the libraries, this completes the
  1489. installation procedure for Turbo C. To install the package's source
  1490. code, we recommend that you create a subdirectory named COMM to hold
  1491. the LiteComm and Xmodem source code. To install the LiteComm source
  1492. code, do the following:
  1493.  
  1494.     o    MD \COMM
  1495.  
  1496.     o    CD \COMM
  1497.  
  1498.     o    ARC E A:LCSRC *.*
  1499.  
  1500.     o    ARC E A:LXMSRC *.*
  1501.  
  1502. We strongly urge that you use the recommended approach in handling the
  1503. source code to avoid naming conflicts that might arise.
  1504.  
  1505. 6.1.2  MAKING NEW TURBO-C LIBRARIES
  1506.  
  1507. It is important to source code registrants to be aware that to
  1508. successfully rebuild the LiteComm or Xmodem libraries, the supplied
  1509. make files assume that you are using Turbo-C version 1.5 or greater,
  1510. and therefore have access to the TLIB program that is a part of
  1511. version 1.5 or greater.  If you are using a version of Turbo-C earlier
  1512. than 1.5, you must have access to LIB.EXE, the Microsoft Librarian
  1513. program, or a suitable replacement. To use the make files included in
  1514. the package under these circumstances, you will have to change the
  1515. make files accordingly to refer to LIB rather than TLIB.
  1516.  
  1517. In addition, to reassemble the interrupt handlers, you must have
  1518. available Borland's TASM that is a part of the Turbo-C Professional
  1519. package or Microsoft's MASM, available as a separate product. The use
  1520. of MASM will require you to make changes to the provided make files.
  1521. Object versions of these handlers have been included for those users
  1522. who do not have TASM available.
  1523.  
  1524.  
  1525.  
  1526.  
  1527.  
  1528.                  Page 24
  1529.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  1530.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  1531.             for Microsoft and Turbo C
  1532.  
  1533.  
  1534.  
  1535. When you specify the use of the LiteComm and Xmodem Engine libraries
  1536. in Turbo C, you may have to fully qualify the library name in your
  1537. .PRJ file, depending upon the version of Turbo-C that you are using,
  1538. even if you have specified the default library directory in the TC
  1539. Options. In earlier versions, the library option tells TC how to look
  1540. for the standard Turbo C libraries, but not any user-provided
  1541. libraries.
  1542.  
  1543. 6.1.3  INSTALLING THE MICROSOFT C VERSION
  1544.  
  1545. In the following discussion, we assume that your regular header files
  1546. are contained in a subdirectory called INCLUDE, and that your
  1547. libraries are in a subdirectory called LIB, as recommended by
  1548. Microsoft. These instructions pertain to both Microsoft QuickC and
  1549. standard C.
  1550.  
  1551. To install the header files used with LiteComm, perform the following
  1552. steps:
  1553.  
  1554.     o    CD INCLUDE
  1555.  
  1556.     o    ARC E A:MCOMM *.H
  1557.  
  1558.     o    ARC E A:MCLIB *.H
  1559.  
  1560. To install the library files, perform the following steps:
  1561.  
  1562.     o    CD LIB
  1563.  
  1564.     o    ARC E A:MCLIB *.LIB
  1565.  
  1566. If you are installing only the libraries, this completes the
  1567. installation procedure for Microsoft C. To install the package's
  1568. source code, we recommend that you create a subdirectory named COMM to
  1569. hold the LiteComm and Xmodem source code. To install the LiteComm
  1570. source code, do the following:
  1571.  
  1572.     o    MD COMM
  1573.  
  1574.     o    CD COMM
  1575.  
  1576.     o    ARC E A:LCSRC *.*
  1577.  
  1578.     o    ARC E A:LXMSRC *.*
  1579.  
  1580. We strongly urge that you use the recommended approach in handling the
  1581. source code to avoid naming conflicts that might arise.
  1582.  
  1583. 6.1.4  MAKING NEW MICROSOFT C LIBRARIES
  1584.  
  1585. It is important to source code registrants to be aware that to
  1586. successfully rebuild the LiteComm or Xmodem libraries, you must have
  1587. access to a copy of LIB.EXE, the Microsoft Librarian program, or a
  1588. suitable replacement. To use the make files included in the package,
  1589.  
  1590.  
  1591.  
  1592.                  Page 25
  1593.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  1594.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  1595.             for Microsoft and Turbo C
  1596.  
  1597.  
  1598.  
  1599. LIB.EXE must either be in your current working directory, or in a
  1600. directory specified in the DOS PATH variable. For additional
  1601. information on setting the PATH variable, consult your DOS manual.
  1602.  
  1603. Microsoft C users need to know that the Microsoft C  version is
  1604. written in, and intended to support Microsoft C version 5.XX and
  1605. QuickC.  The package has not been tested with earlier versions of
  1606. Microsoft C, although we believe that it should function properly with
  1607. version 4.X, although some adjustments may be necessary.
  1608.  
  1609. QuickC users should also note that we have NOT provided a QLB version
  1610. of the libraries.  If you wish to create a QLB version of the
  1611. libraries for use in the QuickC environment, follow the procedures
  1612. outlined on pages 237-ff of the QuickC Programmer's Guide.  Remember,
  1613. the QuickC version 1.0 environment requires the MEDIUM memory model.
  1614. Therefore, unregistered users cannot create a usable QLB library
  1615. following this procedure.  Alternatively, you can use the supplied
  1616. medium model library within the QuickC environment by specifying the
  1617. library as part of a program list.
  1618.  
  1619. Unregistered QuickC users can still use QCL to create usable programs
  1620. with the supplied small model library.  Be sure to use the /AS switch
  1621. when compiling.
  1622.  
  1623.  
  1624. 6.2  GENERAL NOTES
  1625.  
  1626.  
  1627. The LiteComm and related libraries make extensive use of parameters
  1628. defined in the included header files. Where appropriate, your programs
  1629. should always use the same header file parameters. While every effort
  1630. will be made in future releases of LiteComm to preserve the values as
  1631. currently provided, we cannot guarantee that changes will never
  1632. occur.The safest way to safeguard your efforts is to use the defined
  1633. parameters. In this way, a simple recompile and relink will insure
  1634. consistency from one release of LiteComm to the next.
  1635.  
  1636. In the discussion of the various functions which follow, you should
  1637. assume that any references to the port variable refer to a variable or
  1638. constant that may take on a value of from 1 to 4. No other values are
  1639. acceptable, and will be rejected.
  1640.  
  1641. While we feel that LiteComm is written in the most efficient way
  1642. possible, commensurate with good programming practice, we cannot be
  1643. responsible for variations caused by hardware configurations or other
  1644. factors beyond our control. LiteComm has been tested, and is known to
  1645. perform on, the IBM PC-AT, IBM PS/2 and several compatible systems
  1646. such as the Zenith and Wyse equivalents. LiteComm has not been tested
  1647. in environments in which other software, most significantly TSR
  1648. (terminate and stay resident) modules exist. Some TSR programs that
  1649. "steal" interrupts for their own purposes present an unfavorable
  1650. environment to other programs that rely on the interrupt structure of
  1651. the computer.
  1652.  
  1653.  
  1654.  
  1655.  
  1656.                  Page 26
  1657.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  1658.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  1659.             for Microsoft and Turbo C
  1660.  
  1661.  
  1662.  
  1663. Should you experience erratic behavior with LiteComm in a TSR-type
  1664. situation, try executing your application without the TSR module being
  1665. present. If the problems you have experienced disappear, suspect the
  1666. TSR module.
  1667.  
  1668. Conversely, LiteComm provides an excellent vehicle for supporting TSR
  1669. programs that you may write. Since the package is fully re-entrant,
  1670. your only concern need be with those aspects of TSR programs are of
  1671. normal concern, e.g. the non re-entrant nature of DOS. LiteComm never
  1672. uses DOS functions and may therefore be safely used in a TSR
  1673. environment.
  1674.  
  1675. 6.2.1  USE WITH MULTITASKING ENVIRONMENTS
  1676.  
  1677. Some users have made attempts at using LiteComm in conjunction with
  1678. multitasking environments such as Quarterdesk's DesqView.  Use of
  1679. LiteComm in such an environment is certain to be affected by the way
  1680. in which the multitasking behaves with respect to interrupts.
  1681. Although we recognize that DesqView has achieved a certain level of
  1682. popularity among so-called power users, LiteComm was not explicitly
  1683. designed for such environments, and its performance may suffer as a
  1684. result.
  1685.  
  1686. 6.2.2  NOTES ON RING DETECTION
  1687.  
  1688. Several users have reported problems in consistently detecting a
  1689. ringing telephone by checking the state of the RI (Ring Indicator)
  1690. signal.  The problem seems to be highly dependent on the type of modem
  1691. that is being used, since this signal is provided by the modem.  If
  1692. the duration of the signal is too short, the program may miss the
  1693. signal as the modem toggles it on and off.  One workaround that has
  1694. been used successfully is to check the RICHG bit returned from
  1695. lc_mstat, rather than the RI bit.  The RICHG bit will be set when the
  1696. RI bit comes one and again when the RI bit goes off. This is the
  1697. method employed in the check_for_call function.
  1698.  
  1699.  
  1700.  
  1701.  
  1702.  
  1703.  
  1704.  
  1705.  
  1706.  
  1707.  
  1708.  
  1709.  
  1710.  
  1711.  
  1712.  
  1713.  
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720.                  Page 27
  1721.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  1722.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  1723.             for Microsoft and Turbo C
  1724.  
  1725.  
  1726.  
  1727.  
  1728.  
  1729.  
  1730.  
  1731.  
  1732.  
  1733.  
  1734.  
  1735.  
  1736.  
  1737.  
  1738.  
  1739.  
  1740.  
  1741.  
  1742.  
  1743.  
  1744.  
  1745.  
  1746.  
  1747.  
  1748.  
  1749.  
  1750.  
  1751.  
  1752.  
  1753.  
  1754.  
  1755.  
  1756.  
  1757.  
  1758.  
  1759.  
  1760.  
  1761.  
  1762.  
  1763.  
  1764.  
  1765.  
  1766.  
  1767.  
  1768.  
  1769.  
  1770.  
  1771.  
  1772.  
  1773.  
  1774.  
  1775.  
  1776.  
  1777.  
  1778.  
  1779.  
  1780.  
  1781.  
  1782.  
  1783.  
  1784.                  Page 28
  1785.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  1786.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  1787.             for Microsoft and Turbo C
  1788.  
  1789.  
  1790.  
  1791.  
  1792.  
  1793.  
  1794.  
  1795.  
  1796.  
  1797.                   Chapter 7
  1798.  
  1799.               FUNCTION REFERENCE
  1800.  
  1801.  
  1802. In the following pages, we provide the detailed information about each
  1803. of the available LiteComm ToolBox functions.  Each function definition
  1804. includes, at a minimum, a summary of how the function is referenced, a
  1805. description of what the function does, and an indication of those
  1806. values, if any, that the function might perform.
  1807.  
  1808. Where appropriate, we include additional documentation about the
  1809. function.  Some definitions include examples, in the sense of code
  1810. fragments illustrating the function's usage.  More importantly, some
  1811. definitions include additional notes and warnings as well as
  1812. references to other functions within the package.
  1813.  
  1814. We have made every effort to insure that the documentation of the
  1815. functions is complete and accurate.  The style and manner of the
  1816. documentation assumes that the reader is thoroughly familiar with the
  1817. elements of C syntax and common conventions.
  1818.  
  1819.  
  1820.  
  1821.  
  1822.  
  1823.  
  1824.                 _portchg
  1825.  
  1826.  
  1827. SUMMARY
  1828.  
  1829.  
  1830.      #include <litecomm.h>
  1831.  
  1832.      int _portchg(port, base, irq, vector)
  1833.  
  1834.      unsigned port;
  1835.      unsigned base;
  1836.      unsigned vector;
  1837.      char irq;
  1838.  
  1839.  
  1840. DESCRIPTION
  1841.  
  1842.  
  1843. Changes one or more of the critical parameters for COM3 or COM4. This
  1844. function must be used before the port is opened to be effective. To
  1845.  
  1846.  
  1847.  
  1848.                  Page 29
  1849.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  1850.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  1851.             for Microsoft and Turbo C
  1852.  
  1853.  
  1854.  
  1855. leave any of the parameters at its default value, make the
  1856. corresponding entry 0. Note that vector is a vector number, not an
  1857. address or pointer.
  1858.  
  1859. The irq parameter should not be taken to be the irq (interrupt
  1860. request) number, but rather the irq mask. The following lines,
  1861. reproduced from 'litecomm.h' help illustrate this idea.
  1862.  
  1863. #define IRQ1 0x10 /* int req mask for port 1 - irq4 */
  1864. #define IRQ2 0x08 /* int req mask for port 2 - irq3 */
  1865.  
  1866. Note that the value for irq4 is NOT 4, but a character in which bit 4,
  1867. using INTEL's bit numbering, is set to a value of 1. Thus, to use irq
  1868. priority 1 as the irq for either COM3 or COM4, you would specify 0x02
  1869. as the value of irq when calling _portchg.
  1870.  
  1871. The default parameters are shown in the litecomm.h include file.
  1872.  
  1873. If you intend to change the default irq settings, you MUST also make a
  1874. corresponding change to the vector number. See the accompanying
  1875. documentation about using COM3 and COM4 for additional details.
  1876. Failure to follow this rule may make the port appear to be
  1877. nonfunctional.
  1878.  
  1879. The _portchg function does NOT check to determine that you have
  1880. provided both an IRQ mask AND a new vector number.
  1881.  
  1882.  
  1883. EXAMPLE
  1884.  
  1885.  
  1886.      if (_portchg(port, 0x408, 0, 0, 0) == -1)
  1887.      {
  1888.       printf("Error Changing Port %d\n", port);
  1889.       exit(1);
  1890.      }
  1891.  
  1892.  
  1893. RETURN VALUES
  1894.  
  1895.  
  1896. Returns 0 if the function is successful, -1 if you attempt to change a
  1897. port other that 3 or 4.
  1898.  
  1899.  
  1900.  
  1901.  
  1902.  
  1903.  
  1904.  
  1905.  
  1906.  
  1907.  
  1908.  
  1909.  
  1910.  
  1911.  
  1912.                  Page 30
  1913.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  1914.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  1915.             for Microsoft and Turbo C
  1916.  
  1917.  
  1918.  
  1919.  
  1920.  
  1921.  
  1922.  
  1923.  
  1924.  
  1925.                 comm_opn
  1926.  
  1927.  
  1928. SUMMARY
  1929.  
  1930.  
  1931.      #include <litecomm.h>
  1932.  
  1933.      int comm_opn(port, baud, parity, datab, stopb, inbufsz,
  1934.           outbufsz, raisemdm)
  1935.      unsigned port;
  1936.      unsigned baud;
  1937.      unsigned parity;
  1938.      unsigned datab;
  1939.      unsigned stopb;
  1940.      unsigned inbufsz;
  1941.      unsigned outbufsz;
  1942.  
  1943.  
  1944. DESCRIPTION
  1945.  
  1946.  
  1947. Opens the specified port for use and attaches an interrupt handler to
  1948. DOS for the port. Optionally, comm_opn will raise the DTR and RTS
  1949. modem control signals, if the value of raisemdm is TRUE. The function
  1950. allocates, from the heap, space for the CCB (communications control
  1951. block), space for the interrupt handler's stack, and buffers for input
  1952. and output of the specified sizes. The minimum value for inbufsz is
  1953. 128; the minimum size for outbufsz is 64.
  1954.  
  1955. If sufficient memory is available, and a correct set of parameters has
  1956. been specified, the port will be set to the parameters (baud rate,
  1957. word length, stop bits) used when the function is called.  The memory
  1958. overhead associated with opening a port can be approximated by adding
  1959. about 1.2K bytes to the buffer sizes specified.
  1960.  
  1961. comm_opn installs an exit handler using the atexit() function to
  1962. protect DOS from problems that might arise if a program using LiteComm
  1963. fails. However, it is sound practice to close a port opened in this
  1964. manner using comm_close explicitly in your program to gain maximum
  1965. control over the port.
  1966.  
  1967. The baud parameter is an unsigned integer that specifies the baud rate
  1968. you intend to use, e.g. 4800. The other parameters passed to the
  1969. function should be from the parameter set in the litecomm.h include
  1970. file.
  1971.  
  1972.  
  1973.  
  1974.  
  1975.  
  1976.  
  1977.                  Page 31
  1978.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  1979.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  1980.             for Microsoft and Turbo C
  1981.  
  1982.  
  1983.  
  1984. EXAMPLE
  1985.  
  1986.  
  1987. Below are two examples of using comm_opn, the first letting comm_opn
  1988. raise the modem control signals, the second using two function calls
  1989. to accomplish the same end.  The final result of each example is
  1990. exactly the same, an open port on which the DTR and RTS signals have
  1991. been raised.
  1992.  
  1993. Example 1
  1994.  
  1995.      if (comm_opn(port, 1200, NPARITY, BIT8, STOP1, 256,
  1996.           256, TRUE) == - 1)
  1997.      {
  1998.       printf("Error Opening Port %d\n", port);
  1999.       exit(1);
  2000.      }
  2001.  
  2002.  
  2003. Example 2
  2004.      if (comm_opn(port, 1200, NPARITY, BIT8, STOP1, 256,
  2005.           256, FALSE) == - 1)
  2006.      {
  2007.       printf("Error Opening Port %d\n", port);
  2008.       exit(1);
  2009.      }
  2010.      lc_setmdm(port, (DTR | RTS));
  2011.  
  2012.  
  2013. RETURN VALUES
  2014.  
  2015.  
  2016. Upon successful open, the function returns port. If any error occurs,
  2017. regardless of type, the function returns -1.
  2018.  
  2019.  
  2020.  
  2021.  
  2022.  
  2023.  
  2024.                   comm_close
  2025.  
  2026.  
  2027. SUMMARY
  2028.  
  2029.  
  2030.      #include <litecomm.h>
  2031.      int comm_close(port, dropmdm)
  2032.      unsigned port;
  2033.  
  2034.  
  2035.  
  2036.  
  2037.  
  2038.  
  2039.  
  2040.  
  2041.                  Page 32
  2042.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  2043.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  2044.             for Microsoft and Turbo C
  2045.  
  2046.  
  2047.  
  2048. DESCRIPTION
  2049.  
  2050.  
  2051. This function is the companion to comm_opn and, in effect, performs
  2052. the opposite action. Comm_close detaches the library routines from the
  2053. interrupt handler, and reconnects the previous interrupt handler.
  2054. Comm_close also releases all allocated memory used for the buffering
  2055. and control structures described under comm_opn. If the value of
  2056. dropmdm is non-zero, the port is closed absolutely, and all modem
  2057. control signals are dropped.  If the value of dropmdm is zero, the
  2058. port is closed conditionally, and both the DTR and RTS signals will be
  2059. left in their current state.
  2060.  
  2061. Since comm_opn installs an exit handler using the atexit function in
  2062. both Turbo C and Microsoft C, you are not required to explicitly close
  2063. an open port.  However, if you do not explictly close the port, you
  2064. will lose control over the handling of the DTR and RTS signals since
  2065. the built-in exit handler uses the absolute form of the close.
  2066.  
  2067.  
  2068. EXAMPLES
  2069.  
  2070.  
  2071. These are two equivalent examples of the comm_close function.  The
  2072. first uses the absolute port close, the second uses two function calls
  2073. to accomplish the same result.
  2074.  
  2075. Example 1
  2076.  
  2077.      comm_close(port, TRUE);       /* absolute close */
  2078.  
  2079. Example 2
  2080.  
  2081.      lc_clrmdm(port, (RTS | DTR)); /* lower modem control */
  2082.      comm_close(port, FALSE);       /* conditional close */
  2083.  
  2084.  
  2085. RETURN VALUES
  2086.  
  2087.  
  2088. If any error occurs, regardless of type, the function returns -1.
  2089.  
  2090.  
  2091.  
  2092.  
  2093.  
  2094.  
  2095.                   comm_setup
  2096.  
  2097.  
  2098. SUMMARY
  2099.  
  2100.  
  2101.      #include <litecomm.h>
  2102.  
  2103.  
  2104.  
  2105.                  Page 33
  2106.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  2107.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  2108.             for Microsoft and Turbo C
  2109.  
  2110.  
  2111.  
  2112.      int comm_setup(port,baud,parity,datab,stopb)
  2113.  
  2114.      unsigned port;
  2115.      unsigned baud;
  2116.      unsigned parity;
  2117.      unsigned datab;
  2118.      unsigned stopb;
  2119.  
  2120.  
  2121. DESCRIPTION
  2122.  
  2123.  
  2124. The comm_setup function is a subset of the comm_opn function and the
  2125. remarks made in the description of comm_opn regarding the port
  2126. parameters apply.
  2127.  
  2128. This function is useful if you wish to change the basic communication
  2129. parameters of the specified port that has already been opened without
  2130. comm_close'ing the port.
  2131.  
  2132.  
  2133. EXAMPLE
  2134.  
  2135.  
  2136.      if (comm_setup(port, 1200, NPARITY, BIT8, STOP1) == -1)
  2137.      {
  2138.       printf("Error Changing Port %d\n", port);
  2139.       exit(1);
  2140.      }
  2141.  
  2142.  
  2143. RETURN VALUES
  2144.  
  2145.  
  2146. If any error occurs, regardless of type, the function returns -1.
  2147.  
  2148.  
  2149. SEE ALSO
  2150.  
  2151.  
  2152. comm_opn
  2153.  
  2154.  
  2155.  
  2156.  
  2157.  
  2158.  
  2159.                 lc_vport
  2160.  
  2161.  
  2162. SUMMARY
  2163.  
  2164.  
  2165.      #include <litecomm.h>
  2166.  
  2167.  
  2168.  
  2169.                  Page 34
  2170.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  2171.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  2172.             for Microsoft and Turbo C
  2173.  
  2174.  
  2175.  
  2176.      COMM *lc_vport(port)
  2177.  
  2178.  
  2179. DESCRIPTION
  2180.  
  2181.  
  2182. lc_vport is a macro that is used internally to validate that the port
  2183. number specified is correct and has been opened with the comm_opn
  2184. function. It may be of use to you in writing certain applications.
  2185.  
  2186.  
  2187. RETURN VALUES
  2188.  
  2189.  
  2190. If the port is valid and has been opened, returns a pointer to the CCB
  2191. (communications control block) for the port. Returns NULL if an error
  2192. occurs;
  2193.  
  2194.  
  2195.  
  2196.  
  2197.  
  2198.  
  2199.                 lc_icnt
  2200.  
  2201.  
  2202. SUMMARY
  2203.  
  2204.  
  2205.      #include <litecomm.h>
  2206.  
  2207.      int lc_icnt(port)
  2208.      int lc_ocnt(port)
  2209.  
  2210.      unsigned port;
  2211.  
  2212.  
  2213. DESCRIPTION
  2214.  
  2215.  
  2216. These functions may be used to determine the number of characters
  2217. currently in the input(lc_icnt) or output(lc_ocnt) buffers for the
  2218. port.
  2219.  
  2220.  
  2221. EXAMPLE
  2222.  
  2223.  
  2224.      #include <litecomm.h>
  2225.  
  2226.      if (lc_icnt(port))           /* anything received ? */
  2227.      puts("Characters waiting in input");
  2228.  
  2229.  
  2230.  
  2231.  
  2232.  
  2233.                  Page 35
  2234.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  2235.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  2236.             for Microsoft and Turbo C
  2237.  
  2238.  
  2239.  
  2240. RETURN VALUES
  2241.  
  2242.  
  2243. Both functions return -1 if an error occurs (port not open or invalid
  2244. port number). The lc_icnt() function returns the number of characters
  2245. in the input buffer; lc_ocnt() returns the number of characters in the
  2246. transmit buffer that have not yet been sent.
  2247.  
  2248.  
  2249.  
  2250.  
  2251.  
  2252.  
  2253.                 lc_mstat
  2254.  
  2255.  
  2256. SUMMARY
  2257.  
  2258.  
  2259.      #include <litecomm.h>
  2260.  
  2261.      int lc_mstat(port)
  2262.  
  2263.      unsigned port;
  2264.  
  2265.  
  2266. DESCRIPTION
  2267.  
  2268.  
  2269. May be used to determine the last known state of the modem- supplied
  2270. handshake signals. These may be tested using the values in the include
  2271. file litecomm.h.
  2272.  
  2273. The handshake signals consist of a byte in which the bits 4-7 contain
  2274. the current state of the signals (such as Clear To Send or CTS) and
  2275. bits 0-3 contain information regarding whether or not individual
  2276. signals have changed. lc_mstat always returns the current values of
  2277. the signals in bits 4-7.  Bits 0-3 will reflect which, if any, of the
  2278. signals has changed.
  2279.  
  2280. The easiest approach to dealing with the returned value is to test
  2281. bits 0-3 (the DELTA or change bits) for a non-zero value.  If any
  2282. non-zero value is found in bits 0-3, one or more signals have changed
  2283. since the last call to lc_mstat.  PLEASE NOTE: The DELTA bits are
  2284. reset once this function is called.  The value obtained from bits 4-7
  2285. will correctly reflect the current state of the signals.
  2286.  
  2287. To examine individual signals, litecomm.h has #defined symbols for the
  2288. change bits (e.g. CTSCHG), and for the signals themselves (e.g. CTS).
  2289.  
  2290.  
  2291.  
  2292.  
  2293.  
  2294.  
  2295.  
  2296.  
  2297.                  Page 36
  2298.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  2299.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  2300.             for Microsoft and Turbo C
  2301.  
  2302.  
  2303.  
  2304. EXAMPLE
  2305.  
  2306.  
  2307.      int curstat;
  2308.  
  2309.      curstat = lc_mstat(port);        /* get curent values */
  2310.      if (curstat & DCDCHG)        /* DCD changed ? */
  2311.      if (! (curstat & DCD))        /* carrier still on */
  2312.           puts("Remote is off-line, carrier lost");
  2313.  
  2314.  
  2315. RETURN VALUES
  2316.  
  2317.  
  2318. If the port is valid and has been opened, returns the current modem
  2319. status bits. Returns -1 if an error occurs.
  2320.  
  2321.  
  2322.  
  2323.  
  2324.  
  2325.  
  2326.                 lc_estat
  2327.  
  2328.  
  2329. SUMMARY
  2330.  
  2331.  
  2332.      #include <litecomm.h>
  2333.  
  2334.      int lc_estat(port)
  2335.  
  2336.      unsigned port;
  2337.  
  2338.  
  2339. DESCRIPTION
  2340.  
  2341.  
  2342. May be used to determine the last known state of the serial port's
  2343. error status bits. These may be tested using the values in the include
  2344. file litecomm.h.
  2345.  
  2346. The errors that are detected and reported include:
  2347.  
  2348.    1.  ORUNERR - failure to fetch a character from the port before the
  2349.     next character was received.  Usually a problem in the
  2350.     interrupt handler.
  2351.  
  2352.    2.  PARERR - One or more characters were received in which the
  2353.     parity of the character(s) did not match the current parity
  2354.     setting of the port.  Can be caused by line noise, or by other
  2355.     causes.
  2356.  
  2357.  
  2358.  
  2359.  
  2360.  
  2361.                  Page 37
  2362.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  2363.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  2364.             for Microsoft and Turbo C
  2365.  
  2366.  
  2367.  
  2368.    3.  FRMERR - A framing error has occurred.  A character was
  2369.     received that had too few or (more likely) too many bits.
  2370.     Usually caused by line noise.
  2371.  
  2372.  
  2373. RETURN VALUES
  2374.  
  2375.  
  2376. If the port is valid and has been opened, returns the current error
  2377. status bits. Returns -1 if an error occurs.
  2378.  
  2379.  
  2380.  
  2381.  
  2382.  
  2383.  
  2384.                 lc_getw
  2385.  
  2386.  
  2387. SUMMARY
  2388.  
  2389.  
  2390.      #include <litecomm.h>
  2391.  
  2392.      int lc_getw(port)
  2393.  
  2394.      unsigned port;
  2395.  
  2396.  
  2397. DESCRIPTION
  2398.  
  2399.  
  2400. Reads a character from the serial port's input buffer. Waits
  2401. indefinitely until a character is available.  If the port is
  2402. disconnected for any reason, this function will cause a system hang if
  2403. called, so its use should be carefully controlled.
  2404.  
  2405.  
  2406. RETURN VALUES
  2407.  
  2408.  
  2409. Returns the next available character in the input buffer for the port.
  2410. Returns -1 if the port is not active, or if an invalid port number is
  2411. specified.
  2412.  
  2413.  
  2414.  
  2415.  
  2416.  
  2417.  
  2418.  
  2419.  
  2420.  
  2421.  
  2422.  
  2423.  
  2424.  
  2425.                  Page 38
  2426.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  2427.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  2428.             for Microsoft and Turbo C
  2429.  
  2430.  
  2431.  
  2432.  
  2433.  
  2434.  
  2435.  
  2436.  
  2437.  
  2438.                   lc_setmdm
  2439.  
  2440.  
  2441. SUMMARY
  2442.  
  2443.  
  2444.      #include <litecomm.h>
  2445.  
  2446.      int lc_setmdm(port, newset)
  2447.  
  2448.      unsigned port;
  2449.      unsigned newset;
  2450.  
  2451.  
  2452. DESCRIPTION
  2453.  
  2454.  
  2455. Set one or more of the modem control signals. Because of the need to
  2456. always have OUT2 set for interrupt support, the function always
  2457. provides the correct setting for this bit. Use the symbolic #defines
  2458. found in the litecomm.h file.  Many applications will not require this
  2459. function, if they allow comm_opn to raise these two signals.  More
  2460. sophisticated applications may be required to control either or both
  2461. of the signals to provide handshaking with an external device.
  2462.  
  2463.  
  2464. EXAMPLE
  2465.  
  2466.  
  2467.      /* raise the RTS modem control signal */
  2468.       lc_setmdm(port, RTS);
  2469.  
  2470.      /* raise both RTS and DTR */
  2471.       lc_setmdm(port, (RTS | DTR));
  2472.  
  2473.  
  2474. RETURN VALUES
  2475.  
  2476.  
  2477. Returns 0 if the operation was successful, returns -1 otherwise.
  2478.  
  2479.  
  2480. SEE ALSO
  2481.  
  2482.  
  2483.      comm_opn, lc_clrmdm, lc_togmdm
  2484.  
  2485.  
  2486.  
  2487.  
  2488.  
  2489.                  Page 39
  2490.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  2491.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  2492.             for Microsoft and Turbo C
  2493.  
  2494.  
  2495.  
  2496.  
  2497.  
  2498.  
  2499.  
  2500.  
  2501.  
  2502.                   lc_clrmdm
  2503.  
  2504.  
  2505. SUMMARY
  2506.  
  2507.  
  2508.      #include <litecomm.h>
  2509.  
  2510.      int lc_clrmdm(port, newset)
  2511.  
  2512.      unsigned port;
  2513.      unsigned newset;
  2514.  
  2515.  
  2516. DESCRIPTION
  2517.  
  2518.  
  2519. Companion to the setmdm function. Clears the modem control signals RTS
  2520. or DTR or both . Because of the need to always have OUT2 set for
  2521. interrupt support, the function always provides the correct setting
  2522. for this bit. Use the symbolic #defines found in the litecomm.h file.
  2523. Generally, this function only has value if you trying to implement
  2524. some form of hardware handshaking with another device.  The comm_close
  2525. function will lower both RTS and DTS automatically, if told to do so.
  2526.  
  2527.  
  2528. EXAMPLE
  2529.  
  2530.  
  2531.      /* lower the RTS modem control signal */
  2532.       lc_clrmdm(port, RTS);
  2533.  
  2534.      /* lower both RTS and DTR */
  2535.       lc_clrmdm(port, (RTS | DTR));
  2536.  
  2537.  
  2538. RETURN VALUES
  2539.  
  2540.  
  2541. Returns 0 if the operation was successful, returns -1 otherwise.
  2542.  
  2543.  
  2544. SEE ALSO
  2545.  
  2546.  
  2547.      comm_close, lc_setmdm, lc_togmdm
  2548.  
  2549.  
  2550.  
  2551.  
  2552.  
  2553.                  Page 40
  2554.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  2555.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  2556.             for Microsoft and Turbo C
  2557.  
  2558.  
  2559.  
  2560.  
  2561.  
  2562.  
  2563.  
  2564.  
  2565.  
  2566.                   lc_togmdm
  2567.  
  2568.  
  2569. SUMMARY
  2570.  
  2571.  
  2572.      #include <litecomm.h>
  2573.  
  2574.      int lc_togmdm(port, newset)
  2575.  
  2576.      unsigned port;
  2577.      unsigned newset;
  2578.  
  2579.  
  2580. DESCRIPTION
  2581.  
  2582.  
  2583. Companion to setmdm function. Inverts (flip-flops) the modem control
  2584. signals RTS or DTR or both. Because of the need to always have OUT2
  2585. set for interrupt support, the function always provides the correct
  2586. setting for this bit. Use the symbolic #defines found in the
  2587. litecomm.h file.  This function may have value if you are trying to
  2588. implement hardware handshaking.
  2589.  
  2590.  
  2591. EXAMPLE
  2592.  
  2593.  
  2594.      /*
  2595.      ** change the RTS modem control signal to its other
  2596.      ** state (e.g. if raised, lower, and if lowered, raise
  2597.      */
  2598.       lc_togmdm(port, RTS);
  2599.  
  2600.  
  2601. RETURN VALUES
  2602.  
  2603.  
  2604. Returns 0 if the operation was successful, returns -1 otherwise.
  2605.  
  2606.  
  2607. SEE ALSO
  2608.  
  2609.  
  2610. lc_setmdm, lc_clrmdm
  2611.  
  2612.  
  2613.  
  2614.  
  2615.  
  2616.  
  2617.                  Page 41
  2618.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  2619.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  2620.             for Microsoft and Turbo C
  2621.  
  2622.  
  2623.  
  2624.  
  2625.  
  2626.  
  2627.  
  2628.  
  2629.  
  2630.                 lc_xoff
  2631.  
  2632.  
  2633. SUMMARY
  2634.  
  2635.  
  2636.      #include <litecomm.h>
  2637.  
  2638.      int lc_xoff(port, flag)
  2639.  
  2640.      unsigned port;
  2641.      int flag;
  2642.  
  2643.  
  2644. DESCRIPTION
  2645.  
  2646.  
  2647. If flag is non-zero, the function enables the semiautomatic XON-XOFF
  2648. flow control function. If flag is zero (the default setting),
  2649. automatic flow control is disabled.
  2650.  
  2651. When enabled, the LiteComm kernel will automatically transmit an XOFF
  2652. if and when the input buffer is approximately 2/3 full and will
  2653. automatically recognize an XOFF sent by the other device. If the other
  2654. device transmits an XOFF, the kernel will refuse to send any
  2655. characters until the condition is cleared, either by receipt of an
  2656. XON, by calling lc_gotxoff(), or by disabling XON-XOFF altogether.
  2657. The XOFF recognition functionality is implimented in the kernel.  As a
  2658. result, the transmit buffer will continue to accept input from your
  2659. program until the buffer fills completely, even though the information
  2660. will not be sent.  Once the matching XON is received, the contents of
  2661. the transmit buffer will be sent rapidly to the other device.  It is
  2662. possible that the rate with which characters are sent when this occurs
  2663. may cause problems for the other device, depending on its ability to
  2664. handle the data flow.
  2665.  
  2666. If the kernel has sent an XOFF, it is the programmer's responsibility
  2667. to transmit XON when conditions warrant. Use the lc_putxoff function
  2668. to tell if an automatic XOFF has been sent by the kernel. Use the
  2669. lc_gotxoff function to determine if the kernel has detected an XOFF.
  2670.  
  2671. If you intended to implement a protocol that might include the XON-
  2672. XOFF characters, be sure to disable the automatic flow control.
  2673. Failure to do so may result in a system hang.
  2674.  
  2675.  
  2676.  
  2677.  
  2678.  
  2679.  
  2680.  
  2681.                  Page 42
  2682.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  2683.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  2684.             for Microsoft and Turbo C
  2685.  
  2686.  
  2687.  
  2688. RETURN VALUES
  2689.  
  2690.  
  2691. Returns 0 if the operation was successful, returns -1 otherwise.
  2692.  
  2693.  
  2694. SEE ALSO
  2695.  
  2696.  
  2697. lc_gotxoff, lc_putxoff
  2698.  
  2699.  
  2700.  
  2701.  
  2702.  
  2703.  
  2704.                   lc_gotxoff
  2705.  
  2706.  
  2707. SUMMARY
  2708.  
  2709.  
  2710.      #include <litecomm.h>
  2711.  
  2712.      int lc_gotxoff(port)
  2713.  
  2714.      unsigned port;
  2715.  
  2716.  
  2717. DESCRIPTION
  2718.  
  2719.  
  2720. If an XOFF has been received, the port's internal flag will be reset,
  2721. and transmission to the other device will be permitted. If an XON is
  2722. received from the other device, the port's flag will also be reset,
  2723. permitting further transmissions to occur. If you use flow control,
  2724. and the other device never sends an XON after sending an XOFF, a
  2725. system hang is possible. You may wish to call lc_gotxoff periodically
  2726. to test for this condition, and to cause your port to resume
  2727. transmitting characters.
  2728.  
  2729.  
  2730. RETURN VALUES
  2731.  
  2732.  
  2733. Returns a nonzero value if an XOFF was detected, zero if an XOFF was
  2734. not detected. Will return -1 in the case of an error.
  2735.  
  2736.  
  2737. SEE ALSO
  2738.  
  2739.  
  2740. lc_xoff, lc_putxoff
  2741.  
  2742.  
  2743.  
  2744.  
  2745.                  Page 43
  2746.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  2747.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  2748.             for Microsoft and Turbo C
  2749.  
  2750.  
  2751.  
  2752.  
  2753.  
  2754.  
  2755.  
  2756.  
  2757.  
  2758.                   lc_putxoff
  2759.  
  2760.  
  2761. SUMMARY
  2762.  
  2763.  
  2764.      #include <litecomm.h>
  2765.  
  2766.      int lc_putxoff(port)
  2767.  
  2768.      unsigned port;
  2769.  
  2770.  
  2771. DESCRIPTION
  2772.  
  2773.  
  2774. See below for the values returned. If the LiteComm kernel has sent an
  2775. XOFF, the port's internal flag will be reset. Use this function in
  2776. together with transmission of an XON character to the other device to
  2777. permit transmissions to proceed.
  2778.  
  2779.  
  2780. RETURN VALUES
  2781.  
  2782.  
  2783. Returns a nonzero value if XOFF was sent to the other device, zero if
  2784. an XOFF was not sent since the last time the function was called. Will
  2785. return -1 in the case of an error.
  2786.  
  2787.  
  2788. EXAMPLE
  2789.  
  2790.  
  2791.      if (lc_putxoff(port))       /* sent an XOFF ? */
  2792.       lc_put(port, XON);       /* send XON to resume */
  2793.  
  2794.  
  2795. SEE ALSO
  2796.  
  2797.  
  2798. lc_xoff, lc_putxoff
  2799.  
  2800.  
  2801.  
  2802.  
  2803.  
  2804.  
  2805.  
  2806.  
  2807.  
  2808.  
  2809.                  Page 44
  2810.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  2811.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  2812.             for Microsoft and Turbo C
  2813.  
  2814.  
  2815.  
  2816.  
  2817.  
  2818.  
  2819.  
  2820.  
  2821.  
  2822.                 lc_get
  2823.  
  2824.  
  2825. SUMMARY
  2826.  
  2827.  
  2828.      #include <litecomm.h>
  2829.      int lc_get(port)
  2830.  
  2831.      unsigned port;
  2832.  
  2833.  
  2834. DESCRIPTION
  2835.  
  2836.  
  2837. Read a character from the serial port's input buffer.
  2838.  
  2839.  
  2840. RETURN VALUES
  2841.  
  2842.  
  2843. Returns the next available character in the input buffer for the port.
  2844. If you specified other than NO PARITY when the port was opened, you
  2845. may have to remove (make zero), the parity bit before you use the
  2846. character. Returns -1 if the port is not active, or if there are not
  2847. characters in the port's buffer.
  2848.  
  2849.  
  2850. EXAMPLE
  2851.  
  2852.  
  2853.      if ((ch = lc_get(port)) != -1)    /* any chars? */
  2854.       ch &= 0x7f;            /* mask parity */
  2855.  
  2856.  
  2857.  
  2858.  
  2859.  
  2860.  
  2861.                 lc_peek
  2862.  
  2863.  
  2864. SUMMARY
  2865.  
  2866.  
  2867.      #include <litecomm.h>
  2868.  
  2869.      int lc_peek(port)
  2870.  
  2871.  
  2872.  
  2873.                  Page 45
  2874.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  2875.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  2876.             for Microsoft and Turbo C
  2877.  
  2878.  
  2879.  
  2880.      unsigned port;
  2881.  
  2882.  
  2883. DESCRIPTION
  2884.  
  2885.  
  2886. Look at the next character in the serial port's input buffer.
  2887.  
  2888.  
  2889. RETURN VALUES
  2890.  
  2891.  
  2892. Returns the next available character in the input buffer for the port,
  2893. but does not remove the character from the buffer. This allows the
  2894. application to look-ahead by one character in a nondestructive
  2895. fashion. See additional comments under lc_get regarding parity.
  2896. Returns -1 if the port is not active, or if there are no characters in
  2897. the port's buffer.
  2898.  
  2899.  
  2900.  
  2901.  
  2902.  
  2903.  
  2904.                 lc_put
  2905.  
  2906.  
  2907. SUMMARY
  2908.  
  2909.  
  2910.      #include <litecomm.h>
  2911.  
  2912.      int lc_put(port,ch)
  2913.  
  2914.      unsigned port;
  2915.      char ch;
  2916.  
  2917.  
  2918. DESCRIPTION
  2919.  
  2920.  
  2921. Place a character into the serial port's output buffer.
  2922.  
  2923.  
  2924. RETURN VALUES
  2925.  
  2926.  
  2927. Returns 0 if successful. Note that this does not guarantee that the
  2928. character has been sent, only that no errors were detected, and that
  2929. there was room in the transmit buffer for the character. Characters
  2930. are sent from the transmit buffer when the system has time to send
  2931. them, assuming all conditions for transmission are satisified.
  2932. Returns -1 if the port is not active, or if there no room in the
  2933. port's buffer.
  2934.  
  2935.  
  2936.  
  2937.                  Page 46
  2938.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  2939.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  2940.             for Microsoft and Turbo C
  2941.  
  2942.  
  2943.  
  2944.  
  2945.  
  2946.  
  2947.  
  2948.  
  2949.  
  2950.                 lc_gets
  2951.  
  2952.  
  2953. SUMMARY
  2954.  
  2955.  
  2956.      #include <litecomm.h>
  2957.  
  2958.      int lc_gets(port, buff, cnt)
  2959.  
  2960.      unsigned port;
  2961.      char *buff;
  2962.      int cnt;
  2963.  
  2964.  
  2965. DESCRIPTION
  2966.  
  2967.  
  2968. Read a stream of, at most, cnt characters from the serial port's input
  2969. buffer into the buff location. This function is not sensitive to the
  2970. NULL character. Any parity that is set by the other device may have to
  2971. be removed on a character by character basis. See lc_get for
  2972. additional information.
  2973.  
  2974.  
  2975. RETURN VALUES
  2976.  
  2977.  
  2978. Returns the count of characters actually transferred into buff, or -1
  2979. if an error occurs.
  2980.  
  2981.  
  2982.  
  2983.  
  2984.  
  2985.  
  2986.                 lc_puts
  2987.  
  2988.  
  2989. SUMMARY
  2990.  
  2991.  
  2992.      #include <litecomm.h>
  2993.      int lc_puts(port, buff, cnt)
  2994.  
  2995.      unsigned port;
  2996.      char *buff;
  2997.      int cnt;
  2998.  
  2999.  
  3000.  
  3001.                  Page 47
  3002.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  3003.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  3004.             for Microsoft and Turbo C
  3005.  
  3006.  
  3007.  
  3008. DESCRIPTION
  3009.  
  3010.  
  3011. Place a stream of, at most, cnt characters into the serial port's
  3012. output buffer. Any required parity will be supplied by the serial port
  3013. itself.
  3014.  
  3015.  
  3016. RETURN VALUES
  3017.  
  3018.  
  3019. Returns the number of characters actually placed into the buffer. Note
  3020. that this does not guarantee that the characters have been sent, and
  3021. the number of characters transferred to the into the output buffer may
  3022. be less than the actual request. Returns 0 if any error occurs, or if
  3023. there no room in the port's buffer.
  3024.  
  3025.  
  3026.  
  3027.  
  3028.  
  3029.  
  3030.                 lc_flush
  3031.  
  3032.  
  3033. SUMMARY
  3034.  
  3035.  
  3036.      #include <litecomm.h>
  3037.  
  3038.      int lc_tflush(port)
  3039.  
  3040.      int lc_rflush(port)
  3041.  
  3042.      int lc_flshtrue(port, ch)
  3043.  
  3044.      int lc_nflush(port, cnt)
  3045.  
  3046.      unsigned port;
  3047.      char ch;
  3048.      int cnt;
  3049.  
  3050.  
  3051. DESCRIPTION
  3052.  
  3053.  
  3054. The lc_<x>flush functions remove characters from the specified buffer
  3055. and discard them; untransmitted characters in the transmit buffer are
  3056. NEVER sent; unprocessed characters in the receive buffer are lost.  Do
  3057. not try to use the lc_tflush to force characters to be transmitted.
  3058. The tflush function unconditionally empties the transmit buffer,
  3059. discarding any unsent characters.
  3060.  
  3061.     o  lc_tflush empties the port's transmit buffer immediately.
  3062.  
  3063.  
  3064.  
  3065.                  Page 48
  3066.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  3067.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  3068.             for Microsoft and Turbo C
  3069.  
  3070.  
  3071.  
  3072.     o    lc_rflush empties the port's receive buffer immediately.
  3073.  
  3074.     o    lc_flshtrue will continually dispose of received characters
  3075.     until the character ch is received. Use caution with this one
  3076.     since it does not detect port number errors, and will appear to
  3077.     seize the system until the demanded character is received.
  3078.  
  3079.     o    lc_nflush flushes, at most, cnt characters from the port's
  3080.     receive buffer.
  3081.  
  3082.  
  3083. RETURN VALUES
  3084.  
  3085.  
  3086. lc_flshtrue returns no values. lc_tflush and lc_rflush return 0 if
  3087. successful and -1 if an error occurs. lc_nflush returns the number of
  3088. characters actually flushed from the receive buffer or 0 in the case
  3089. of no characters to flush, or if an error was detected.
  3090.  
  3091.  
  3092.  
  3093.  
  3094.  
  3095.  
  3096.                 lc_sbrk
  3097.  
  3098.  
  3099. SUMMARY
  3100.  
  3101.  
  3102.      #include <litecomm.h>
  3103.  
  3104.      int lc_sbrk(port)
  3105.  
  3106.      lc_gotbrk(port)
  3107.  
  3108.      unsigned port;
  3109.  
  3110.  
  3111. DESCRIPTION
  3112.  
  3113.  
  3114. lc_sbrk() generates a BREAK signal using a particular characteristic
  3115. of the 8250 UART family to generate an accurate BREAK at any baud
  3116. rate.  BREAKs generated in this manner are timed based upon the baud
  3117. rate at which the 8250 is currently initialized.  This function may or
  3118. may not work correctly with other than the actual 8250 UART or its
  3119. relatives.
  3120.  
  3121.  
  3122.  
  3123.  
  3124.  
  3125.  
  3126.  
  3127.  
  3128.  
  3129.                  Page 49
  3130.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  3131.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  3132.             for Microsoft and Turbo C
  3133.  
  3134.  
  3135.  
  3136. RETURN VALUES
  3137.  
  3138.  
  3139. lc_gotbrk returns a nonzero value if a break signal has been received
  3140. on the specified port.  It returns zero otherwise.
  3141.  
  3142. lc_sbrk Returns 0 if successful. Returns -1 if the port is not active.
  3143.  
  3144.  
  3145.  
  3146.  
  3147.  
  3148.  
  3149.  
  3150.  
  3151.  
  3152.  
  3153.  
  3154.  
  3155.  
  3156.  
  3157.  
  3158.  
  3159.  
  3160.  
  3161.  
  3162.  
  3163.  
  3164.  
  3165.  
  3166.  
  3167.  
  3168.  
  3169.  
  3170.  
  3171.  
  3172.  
  3173.  
  3174.  
  3175.  
  3176.  
  3177.  
  3178.  
  3179.  
  3180.  
  3181.  
  3182.  
  3183.  
  3184.  
  3185.  
  3186.  
  3187.  
  3188.  
  3189.  
  3190.  
  3191.  
  3192.  
  3193.                  Page 50
  3194.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  3195.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  3196.             for Microsoft and Turbo C
  3197.  
  3198.  
  3199.  
  3200.  
  3201.  
  3202.  
  3203.  
  3204.  
  3205.  
  3206.                   Chapter 8
  3207.  
  3208.             BBS SUPPORT FUNCTIONS
  3209.  
  3210.  
  3211. 8.1  INTRODUCTION
  3212.  
  3213.  
  3214. In this chapter, we discuss a set of utility functions that were
  3215. originally developed as a part of a new, and as yet unannounced BBS
  3216. package in conjunction with one of our registered users.  Not only are
  3217. they useful, in and of themselves, but they also act as examples of
  3218. using the LiteComm ToolBox in situations that puzzle some users.
  3219.  
  3220.  
  3221. 8.2  ADDITIONAL NOTES
  3222.  
  3223.  
  3224. The use of any of the functions that follow in this section require
  3225. that you define, in your code, three modem setup strings with the
  3226. names MODEMSET0, MODEMSET1, and MODEMSET2, and must be pointers to
  3227. characters.  In addition, they must be defined as global variables,
  3228. and must be public (i.e. not static). One way to accomplish this is
  3229. shown below.
  3230.  
  3231.      char istrng0[] = "ATZ\r";
  3232.      char istrng1] = "ATT E0 V0 X1 M1\r";
  3233.      char istrng2[] = "ATS0=1\r";
  3234.  
  3235.      char *MODEMSET0;
  3236.      char *MODEMSET1;
  3237.      char *MODEMSET2;
  3238.  
  3239.      void main(void)
  3240.      {
  3241.     ...
  3242.     MODEMSET0 = &istrng0[0];
  3243.     MODEMSET1 = &istrng1[0];
  3244.     MODEMSET2 = &istrng2[0];
  3245.     ...
  3246.      }
  3247.  
  3248. Experienced C programmers will readily recognize that this is not
  3249. necessarily the best approach.  But it does serve to clearly
  3250. illustrate the concepts involved.  Be certain that MODEMSET0, 1, and 2
  3251. are defined as pointers to characters as shown above, and NOT as
  3252. arrays.  It is a fine destinction in C, but an important one.
  3253.  
  3254.  
  3255.  
  3256.  
  3257.                  Page 51
  3258.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  3259.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  3260.             for Microsoft and Turbo C
  3261.  
  3262.  
  3263.  
  3264.  
  3265.  
  3266.  
  3267.  
  3268.  
  3269.  
  3270.                   new_event
  3271.  
  3272.  
  3273. SUMMARY
  3274.  
  3275.  
  3276.      include "lcbbs.h";
  3277.  
  3278.      long new_event(sec);
  3279.      int check_event(evtimer);
  3280.  
  3281.      unsinged sec;
  3282.      long evtimer;
  3283.  
  3284.  
  3285. DESCRIPTION
  3286.  
  3287.  
  3288. The new_event function creates an 'event timer' that will expire in
  3289. sec seconds.  This function relies upon the calculation of an absolute
  3290. time value, based upon current date and time, and does not tie into
  3291. any system interrupt, permitting as many independent timeout timers as
  3292. required by your application.
  3293.  
  3294. The check_event function examines the contents of an event timer
  3295. created by new_event with respect to the current date and time, and
  3296. indicates whether or not the timer has expired.
  3297.  
  3298. Do not attempt to use check_event against a variable that was not set
  3299. by new_event.  If you do so, the results are unpredictable and may
  3300. result in a seeming system hang.
  3301.  
  3302.  
  3303. RETURN VALUES
  3304.  
  3305.  
  3306. The new_event function returns a value that represents a point in time
  3307. sec seconds from the time that new_event was called. The check_event
  3308. function returns a nonzero value if the specified event timer has
  3309. expired, a value of zero otherwise.
  3310.  
  3311.  
  3312. EXAMPLE
  3313.  
  3314.  
  3315.      long cdtimer;
  3316.  
  3317.      cdtimer = new_event(30); /* 30 second timer */
  3318.  
  3319.  
  3320.  
  3321.                  Page 52
  3322.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  3323.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  3324.             for Microsoft and Turbo C
  3325.  
  3326.  
  3327.  
  3328.      while( ! check_event(cdtimer))
  3329.       if (check_for_call(port) > 0)
  3330.       {
  3331.         cprintf("Incoming call\r\n");
  3332.         return(1);
  3333.       }
  3334.  
  3335.      cprintf("No calls in 30 seconds\r\n");
  3336.      return(0);
  3337.  
  3338.  
  3339.  
  3340.  
  3341.  
  3342.  
  3343.                 check_for_call
  3344.  
  3345.  
  3346. SUMMARY
  3347.  
  3348.  
  3349.      include "lcbbs.h";
  3350.  
  3351.      int check_for_call(port)
  3352.      unsigned port;
  3353.  
  3354.  
  3355. DESCRIPTION
  3356.  
  3357.  
  3358. This function checks the status of the specified port to determine
  3359. whether or not 1) there is an incoming call and 2) waits for up to 30
  3360. seconds for carrier to be established with the caller if the phone
  3361. rang.  Please note that this function relies upon, in part, the HAYES
  3362. command set.  Use with other than HAYES-compatible modems may result
  3363. in unexpected hangs or other, unpredictable results.  The function
  3364. assumes that the modem parameters have been set in the manner
  3365. described in the reset_modem function.
  3366.  
  3367. In the event that a wrong number call is received, check_for_call will
  3368. automatically disconnect by lowering  the DTR(Data Terminal Ready)
  3369. signal momentarily, then automatically call the reset_modem function.
  3370. See the notes at the beginning of this chapter, and in the discussion
  3371. of the reset_modem function.  This disconnect method, while absolute,
  3372. will only work correctly if you HAVE NOT set your modem to ignore the
  3373. DTR signals, as is possible with some modems.  Please consult your
  3374. modem's documentation for additional detail.
  3375.  
  3376.  
  3377. RETURN VALUES
  3378.  
  3379.  
  3380. If the phone was not ringing, the function return a value of zero.  If
  3381. a ring was detected, but carrier was not detected within 30 seconds,,
  3382.  
  3383.  
  3384.  
  3385.                  Page 53
  3386.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  3387.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  3388.             for Microsoft and Turbo C
  3389.  
  3390.  
  3391.  
  3392. the function will return a value of -1 after forcing a disconnect and
  3393. resetting the modem.  Otherwise, the numeric result code, in integer
  3394. form, is returned.  It is the programmer's responsibility to interpret
  3395. and act upon the result code.  For the function to work properly, the
  3396. modem must be set to return numeric result codes rather than word
  3397. result codes.
  3398.  
  3399.  
  3400.  
  3401.  
  3402.  
  3403.  
  3404.                get_modem_reply
  3405.  
  3406.  
  3407. SUMMARY
  3408.  
  3409.  
  3410.      include "lcbbs.h"
  3411.  
  3412.      int get_modem_reply(port)
  3413.      unsigned port;
  3414.  
  3415.  
  3416. DESCRIPTION
  3417.  
  3418.  
  3419. The get_modem_reply function is intended for use after a command has
  3420. been issued to a HAYES compatible modem.  To operate properly, the
  3421. modem must be set to return numeric responses rather than word
  3422. responses.  The function returns to the caller when one of the
  3423. following occurs:
  3424.  
  3425.    1.    no response from the modem within 1 second.
  3426.  
  3427.    2.    more than 2 response characters received before a <CR> is
  3428.     detected.
  3429.  
  3430.    3.    a <CR> is received from the modem.
  3431.  
  3432. Due to the internal logic employed, the programmer should call this
  3433. function, or purge the receive buffer, after each command sent to the
  3434. modem.  Failure to do so will result in improper interpretation of the
  3435. result codes returned.
  3436.  
  3437.  
  3438. RETURN VALUES
  3439.  
  3440.  
  3441. Returns a value of -1 if no response from the modem is detected within
  3442. 1 second.  Otherwise returns the integer result code.  If the modem
  3443. has not been set to return numeric result codes, the results are
  3444. unpredictable.
  3445.  
  3446.  
  3447.  
  3448.  
  3449.                  Page 54
  3450.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  3451.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  3452.             for Microsoft and Turbo C
  3453.  
  3454.  
  3455.  
  3456.  
  3457.  
  3458.  
  3459.  
  3460.  
  3461.  
  3462.                  reset_modem
  3463.  
  3464.  
  3465. SUMMARY
  3466.  
  3467.  
  3468.      include "lcbbs.h"
  3469.  
  3470.      int reset_modem(port)
  3471.      unsigned port;
  3472.  
  3473.  
  3474. DESCRIPTION
  3475.  
  3476.  
  3477. The reset_modem function initializes the modem to a known state,
  3478. suitable for use with the other bbs functions, and based upon a set of
  3479. initialization strings provided by the user's program.  See the notes
  3480. at the beginning of this chapter for additional information regarding
  3481. the way that this must be done.
  3482.  
  3483. Because the modem-related functions in this section make certain
  3484. assumptions about the modem, your initialization strings should
  3485. include, at a minimum, the following:
  3486.  
  3487.     o    no command echo
  3488.  
  3489.     o    detect carrier
  3490.  
  3491.     o    return numeric result codes
  3492.  
  3493.     o    answer the phone on the first ring (if you need to use the
  3494.     check_for_call function)
  3495.  
  3496. A sample set of initialization strings is shown at the start of this
  3497. chapter. If you require any additional information on these or related
  3498. options, please consult your modem's documentation.
  3499.  
  3500.  
  3501. RETURN VALUES
  3502.  
  3503.  
  3504. The reset_modem function returns the same result code as those
  3505. specified for get_modem_reply.
  3506.  
  3507.  
  3508.  
  3509.  
  3510.  
  3511.  
  3512.  
  3513.                  Page 55
  3514.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  3515.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  3516.             for Microsoft and Turbo C
  3517.  
  3518.  
  3519.  
  3520.  
  3521.  
  3522.  
  3523.  
  3524.  
  3525.  
  3526.                   disconnect
  3527.  
  3528.  
  3529. SUMMARY
  3530.  
  3531.  
  3532.      include "lcbbs.h"
  3533.  
  3534.      void disconnect(port)
  3535.      unsigned port;
  3536.  
  3537.  
  3538. DESCRIPTION
  3539.  
  3540.  
  3541. The disconnect forcibly disconnects the modem from the telephone line
  3542. by lowering the DTR signal momentarily.  You must be certain that your
  3543. modem IS NOT set to ignore the DTR signal for the function to work
  3544. properly.
  3545.  
  3546.  
  3547. RETURN VALUES
  3548.  
  3549.  
  3550. disconnect returns no values.
  3551.  
  3552.  
  3553.  
  3554.  
  3555.  
  3556.  
  3557.  
  3558.  
  3559.  
  3560.  
  3561.  
  3562.  
  3563.  
  3564.  
  3565.  
  3566.  
  3567.  
  3568.  
  3569.  
  3570.  
  3571.  
  3572.  
  3573.  
  3574.  
  3575.  
  3576.  
  3577.                  Page 56
  3578.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  3579.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  3580.             for Microsoft and Turbo C
  3581.  
  3582.  
  3583.  
  3584.  
  3585.  
  3586.  
  3587.  
  3588.  
  3589.  
  3590.                   Chapter 9
  3591.  
  3592.             HAYES MODEM FUNCTIONS
  3593.  
  3594.  
  3595. Note - When using the following functions, you must include the file
  3596. litehcm.h in your program. litehcm.h automatically includes the
  3597. litecomm.h header file.
  3598.  
  3599.  
  3600. 9.1  FUNCTIONS
  3601.  
  3602.  
  3603.     lch_codeset
  3604.     lch_dial
  3605.     lch_fduplex
  3606.     lch_hduplex
  3607.     lch_greg
  3608.     lch_sreg
  3609.     lch_offcarr
  3610.     lch_oncarr
  3611.     lch_offecho
  3612.     lch_onecho
  3613.     lch_hook
  3614.     lch_redo
  3615.     lch_numres
  3616.     lch_wrdres
  3617.     lch_codesoff
  3618.     lch_codeson
  3619.     lch_pulse
  3620.     lch_tone
  3621.     lch_speaker
  3622.     _retset
  3623.     _rettype
  3624.  
  3625.  
  3626. SUMMARY
  3627.  
  3628.  
  3629.     #include <litehcm.h>
  3630.  
  3631.     int lch_codeset(port,mode)
  3632.  
  3633.     int lch_dial(port,dstr)
  3634.  
  3635.     int lch_fduplex(port)
  3636.  
  3637.     int lch_hduplex(port)
  3638.  
  3639.  
  3640.  
  3641.                  Page 57
  3642.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  3643.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  3644.             for Microsoft and Turbo C
  3645.  
  3646.  
  3647.  
  3648.     int lch_greg(port,reg)
  3649.  
  3650.     int lch_sreg(port,reg,value)
  3651.  
  3652.     int lch_offcarr(port)
  3653.  
  3654.     int lch_oncarr(port)
  3655.  
  3656.     int lch_offecho(port)
  3657.  
  3658.     int lch_onecho(port)
  3659.  
  3660.     int lch_hook(port,hmode)
  3661.  
  3662.     int lch_redo(port)
  3663.  
  3664.     int lch_numres(port)
  3665.  
  3666.     int lch_wrdres(port)
  3667.  
  3668.     int lch_codesoff(port)
  3669.  
  3670.     int lch_codeson(port)
  3671.  
  3672.     int lch_pulse(port)
  3673.  
  3674.     int lch_tone(port)
  3675.  
  3676.     int lch_speaker(port,spkmode)
  3677.  
  3678.     int _retset()
  3679.  
  3680.     int _rettype()
  3681.  
  3682.     unsigned port;
  3683.     unsigned mode;
  3684.     char *dstr;
  3685.     unsigned reg;
  3686.     int value;
  3687.     unsigned hmode;
  3688.     unsigned spkmode;
  3689.  
  3690.  
  3691. DESCRIPTION
  3692.  
  3693.  
  3694. The values to be used in conjunction with mode, hmode, and spkmode are
  3695. defined symbolically in the #include file, litehcm.h.
  3696.  
  3697. The lch_codeset function allows you to change the set of codes that
  3698. are returned by the modem when an action is specified.
  3699.  
  3700. lch_dial instructs the modem to dial the number contained in dstr. Do
  3701. not include the dialing (ATD) prefix, or the trailing <\r>. These are
  3702.  
  3703.  
  3704.  
  3705.                  Page 58
  3706.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  3707.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  3708.             for Microsoft and Turbo C
  3709.  
  3710.  
  3711.  
  3712. provided by the function. You may include non-numeric characters that
  3713. are acceptable to your modem, since the contents of dstr are not
  3714. checked. The dialing is done in the last known mode, either pulse or
  3715. tone. If you use the lch_pulse or lch_tone functions, then dialing
  3716. will be done in the mode that was last correctly enabled. If you have
  3717. not exercised these functions, then dialing occurs in the modems
  3718. default or power-up mode.
  3719.  
  3720. The lch_hduplex and lch_fduplex functions place the modem into local
  3721. echo and remote echo modes respectively.
  3722.  
  3723. The lch_greg function requests that the modem report the current value
  3724. of S-register reg. Reg must be in the range 0 to 13. Use the lch_gets,
  3725. or similar function, to retrieve the modem's response. Specifying a
  3726. register outside the 0 to 13 range will cause a return of -1.
  3727.  
  3728. lch_sreg is the companion to lch_greg, with the same restrictions.
  3729. Sets the S-register reg to the value contained in value. If value
  3730. contains -1, then the register is reset to its default (power-up)
  3731. value. The function checks the value to be certain that it is within
  3732. the limits specified for the particular register, and returns a value
  3733. of -1 if the value is outside the predefined limits.
  3734.  
  3735. lch_offcarr enables modem carrier detect, but disables the modem's
  3736. carrier signal. The lch_oncarr companion enables both carrier detect
  3737. and the modems carrier signal. When lch_offcarr is used the modem will
  3738. receive data but will be unable to send data.
  3739.  
  3740. The lch_offecho and lch_onecho functions determine whether commands
  3741. sent to the modem are echoed back to the sending program. With echo
  3742. turned off, the modem will continue to accept commands, but will not
  3743. try to redisplay the command's characters.
  3744.  
  3745. lch_hook allows you to control the current status of the modem's
  3746. telephone line connection. See your modem's documentation and the
  3747. include file for additional information.
  3748.  
  3749. The lch_redo function instructs the modem to repeat the last command
  3750. sequence executed. Generally, this function is of greatest value in
  3751. redialing numbers that are busy, although its use is not restricted to
  3752. that.
  3753.  
  3754. The way in which your modem responds to commands is determined, in
  3755. part, by the lch_wrdres and lch_numres functions. If you call
  3756. lch_wrdres, then modem responses use the English language response
  3757. codes, e.g. CONNECT or OK. Calling lch_numres instructs the modem to
  3758. respond with code numbers only from the currently selected response
  3759. set, see the lch_codeset function above.
  3760.  
  3761. You may use the functions lch_codeson and lch_codesoff to specify
  3762. whether you want your modem to send back response codes when it
  3763. receives a command string. In a sense, these act as companions to the
  3764. lch_xxxecho functions above.
  3765.  
  3766.  
  3767.  
  3768.  
  3769.                  Page 59
  3770.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  3771.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  3772.             for Microsoft and Turbo C
  3773.  
  3774.  
  3775.  
  3776. Use the lch_speaker function to control the modem's internal speaker,
  3777. if it has one. See litehcm.h for the applicable codes.
  3778.  
  3779. The _retset and _rettype functions return, respectively, the last
  3780. known command set (lch_codeset) and last known result type
  3781. (lch_wrdres, lch_numres). These functions (_retset, _rettype) are only
  3782. of value when used in conjunction with the companion functions.
  3783.  
  3784.  
  3785. 9.2  GENERAL REMARKS
  3786.  
  3787.  
  3788. Several considerations are in order if you intend to use the Hayes
  3789. ToolBox functions.
  3790.  
  3791.    1.    You are responsible for checking the return codes from the
  3792.     modem once you have given modem a command. To make the task
  3793.     easier, we suggest that you turn OFF command echo (so that you
  3794.     don't have to worry about separating commands from responses)
  3795.     and turn ON numeric responses (to make the interpretation of
  3796.     result codes easier and faster).
  3797.  
  3798.    2.    Be sure that you allow  adequate time between commands for the
  3799.     modem to process the command and respond. Failure to observe
  3800.     this rule may result in commands being misinterpreted or
  3801.     "lost". You can monitor the number of characters in the receive
  3802.     buffer to help you with the timing. Or alternatively, check the
  3803.     response after each command. The latter approach is more in
  3804.     line with what we believe to be good programming practice.
  3805.  
  3806. RETURN VALUES
  3807. All functions return a value of -1 if a port or other error is
  3808. detected, zero otherwise.
  3809.  
  3810.  
  3811.  
  3812.  
  3813.  
  3814.  
  3815.                   Index
  3816.  
  3817.  
  3818.     8250 7            BIOS functions 21
  3819.     8259 19            bit number 30
  3820.     _portchg 19        BREAK 12, 49
  3821.                 buffers 14, 31
  3822.     A
  3823.     ASP 1            C
  3824.     atexit 14, 33        CCB 31, 35
  3825.                 character length 11
  3826.     B            COM3 30
  3827.     base port 9        COM4 30
  3828.     baud rate 10        control block 14
  3829.     BIOS 20            CTS 36
  3830.  
  3831.  
  3832.  
  3833.                  Page 60
  3834.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  3835.           LITECOMM (TM) COMMUNICATIONS TOOLBOX
  3836.             for Microsoft and Turbo C
  3837.  
  3838.  
  3839.  
  3840.     D            N
  3841.     data overrun error 15    numeric result code 54
  3842.     data path 7
  3843.     Data Terminal Ready    O
  3844.       See: DTR        OUT2 12
  3845.     DesqView 27
  3846.     dialing 58        P
  3847.     DTR 12, 14, 53, 56    parallel 7
  3848.                 parity 11, 45, 46, 47,
  3849.     E               48
  3850.     event timer 52        parity error 15
  3851.                 poll 8
  3852.     F            port 26
  3853.     flow control 42
  3854.     framing error 15        Q
  3855.                 QLB 26
  3856.     H            QuickC 26
  3857.     handshake 36
  3858.     handshaking 12, 13    R
  3859.     HAYES 53, 54        Request To Send See:
  3860.                    RTS
  3861.     I            RTS 12, 14
  3862.     interrupt 8
  3863.     interrupt enable flag    S
  3864.       15            S-register 59
  3865.     interrupt request 19    serial port 7
  3866.     Interrupt Service    stack 31
  3867.       Routine 9        structure alignment 15
  3868.     interrupt vector 19
  3869.     IRQ 20            T
  3870.     ISR 9            TSR 26
  3871.  
  3872.     M            U
  3873.     make 24            UART 7
  3874.     Memory 14
  3875.     modem control 12        X
  3876.     modem status 13        XOFF 42, 43, 44
  3877.     multitasking 27        XON 42, 43, 44
  3878.  
  3879.  
  3880.  
  3881.  
  3882.  
  3883.  
  3884.  
  3885.  
  3886.  
  3887.  
  3888.  
  3889.  
  3890.  
  3891.  
  3892.  
  3893.  
  3894.  
  3895.  
  3896.  
  3897.                  Page 61
  3898.      Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  3899.  
  3900.  
  3901.  
  3902.  
  3903.  
  3904.  
  3905.  
  3906.  
  3907.  
  3908.  
  3909.  
  3910.               Contents
  3911.  
  3912.  
  3913.  
  3914.      Chapter 1  OVERVIEW                   1
  3915.     1.1  FEATURES  . . . . . . . . . . . . . . . . . . 1
  3916.     1.2  THE SHAREWARE CONCEPT . . . . . . . . . . . . 1
  3917.  
  3918.      Chapter 2  LICENSE, WARRANTY AND REGISTRATION       3
  3919.     2.1  LICENSE . . . . . . . . . . . . . . . . . . . 3
  3920.     2.2  WARRANTY  . . . . . . . . . . . . . . . . . . 4
  3921.     2.3  REGISTERING YOUR COPY . . . . . . . . . . . . 4
  3922.     2.4  NOTE  . . . . . . . . . . . . . . . . . . . . 5
  3923.  
  3924.      Chapter 3  Serial Port Fundamentals           7
  3925.     3.1  The 8250 UART family  . . . . . . . . . . . . 7
  3926.     3.2  Purpose of the port . . . . . . . . . . . . . 7
  3927.     3.3  Internal Details  . . . . . . . . . . . . . . 8
  3928.        3.3.1  The Interrupt Connection . . . . . . . . 8
  3929.        3.3.2  The Programmable Port Registers  . . . . 9
  3930.           3.3.2.1  register 0 - transmit/receive . .  10
  3931.           3.3.2.2  register 0 - baud rate selection . 10
  3932.           3.3.2.3  register 1 - interrupt enable . .  10
  3933.           3.3.2.4  register 1 - baud rate selection . 11
  3934.           3.3.2.5  register 2 - interrupt
  3935.             identification . . . . . . . . .  11
  3936.           3.3.2.6  register 3 - line control . . . .  11
  3937.           3.3.2.7  register 4 - modem control  . . .  12
  3938.           3.3.2.8  register 5 - line status  . . . .  12
  3939.           3.3.2.9  register 6 - modem status . . . .  13
  3940.     3.4  The LiteComm Connection . . . . . . . . . .  13
  3941.     3.5  ToolBox NOTES AND WARNINGS  . . . . . . . .  14
  3942.  
  3943.      Chapter 4  RECENT CHANGES                  17
  3944.     4.1  NEW IN VERSION 5.00 . . . . . . . . . . . .  17
  3945.  
  3946.      Chapter 5  BEYOND COM2                  19
  3947.     5.1  THE ToolBox METHODOLOGY . . . . . . . . . .  19
  3948.     5.2  CAUTIONS  . . . . . . . . . . . . . . . . .  20
  3949.  
  3950.      Chapter 6  PACKAGE CONTENTS              23
  3951.     6.1  COMPILER-SPECIFIC INSTRUCTIONS  . . . . . .  23
  3952.        6.1.1  INSTALLING THE TURBO C VERSION . . . .  23
  3953.        6.1.2  MAKING NEW TURBO-C LIBRARIES . . . . .  24
  3954.        6.1.3  INSTALLING THE MICROSOFT C VERSION . .  25
  3955.        6.1.4  MAKING NEW MICROSOFT C LIBRARIES . . .  25
  3956.     6.2  GENERAL NOTES . . . . . . . . . . . . . . .  26
  3957.        6.2.1  USE WITH MULTITASKING ENVIRONMENTS . .  27
  3958.  
  3959.  
  3960.  
  3961.                 i
  3962.  
  3963.  
  3964.  
  3965.  
  3966.  
  3967.  
  3968.        6.2.2  NOTES ON RING DETECTION  . . . . . .  27
  3969.  
  3970.      Chapter 7  FUNCTION REFERENCE            29
  3971.  
  3972.      _portchg                        29
  3973.  
  3974.      comm_opn                        31
  3975.  
  3976.      comm_close                        32
  3977.  
  3978.      comm_setup                        33
  3979.  
  3980.      lc_vport                        34
  3981.  
  3982.      lc_icnt                        35
  3983.  
  3984.      lc_mstat                        36
  3985.  
  3986.      lc_estat                        37
  3987.  
  3988.      lc_getw                        38
  3989.  
  3990.      lc_setmdm                        39
  3991.  
  3992.      lc_clrmdm                        40
  3993.  
  3994.      lc_togmdm                        41
  3995.  
  3996.      lc_xoff                        42
  3997.  
  3998.      lc_gotxoff                        43
  3999.  
  4000.      lc_putxoff                        44
  4001.  
  4002.      lc_get                        45
  4003.  
  4004.      lc_peek                        45
  4005.  
  4006.      lc_put                        46
  4007.  
  4008.      lc_gets                        47
  4009.  
  4010.      lc_puts                        47
  4011.  
  4012.      lc_flush                        48
  4013.  
  4014.      lc_sbrk                        49
  4015.  
  4016.      Chapter 8  BBS SUPPORT FUNCTIONS            51
  4017.     8.1  INTRODUCTION  . . . . . . . . . . . . . .  51
  4018.     8.2  ADDITIONAL NOTES  . . . . . . . . . . . .  51
  4019.  
  4020.      new_event                        52
  4021.  
  4022.  
  4023.  
  4024.  
  4025.                 ii
  4026.  
  4027.  
  4028.  
  4029.  
  4030.  
  4031.  
  4032.      check_for_call                    53
  4033.  
  4034.      get_modem_reply                    54
  4035.  
  4036.      reset_modem                    55
  4037.  
  4038.      disconnect                        56
  4039.  
  4040.      Chapter 9  HAYES MODEM FUNCTIONS            57
  4041.     9.1  FUNCTIONS . . . . . . . . . . . . . . . .  57
  4042.     9.2  GENERAL REMARKS . . . . . . . . . . . . .  60
  4043.  
  4044.      Index                        61
  4045.  
  4046.  
  4047.  
  4048.  
  4049.  
  4050.  
  4051.  
  4052.  
  4053.  
  4054.  
  4055.  
  4056.  
  4057.  
  4058.  
  4059.  
  4060.  
  4061.  
  4062.  
  4063.  
  4064.  
  4065.  
  4066.  
  4067.  
  4068.  
  4069.  
  4070.  
  4071.  
  4072.  
  4073.  
  4074.  
  4075.  
  4076.  
  4077.  
  4078.  
  4079.  
  4080.  
  4081.  
  4082.  
  4083.  
  4084.  
  4085.  
  4086.  
  4087.  
  4088.  
  4089.                 iii
  4090.  
  4091.  
  4092.  
  4093.  
  4094.  
  4095.  
  4096.  
  4097.  
  4098.  
  4099.  
  4100.  
  4101.  
  4102.               Figures
  4103.  
  4104.  
  4105.      Figure 3.1: Register 1 Bit Definitions  . . . . . . .10
  4106.      Figure 3.2: Register 2 Bit Definitions  . . . . . . .11
  4107.      Figure 3.3: Register 3 Bit Definitions  . . . . . . .12
  4108.      Figure 3.4: Register 4 Bit Definitions  . . . . . . .12
  4109.      Figure 3.5: Register 5 Bit Definitions  . . . . . . .13
  4110.      Figure 3.6: Register 6 Bit Definitions  . . . . . . .13
  4111.  
  4112.  
  4113.  
  4114.  
  4115.  
  4116.  
  4117.  
  4118.  
  4119.  
  4120.  
  4121.  
  4122.  
  4123.  
  4124.  
  4125.  
  4126.  
  4127.  
  4128.  
  4129.  
  4130.  
  4131.  
  4132.  
  4133.  
  4134.  
  4135.  
  4136.  
  4137.  
  4138.  
  4139.  
  4140.  
  4141.  
  4142.  
  4143.  
  4144.  
  4145.  
  4146.  
  4147.  
  4148.  
  4149.  
  4150.  
  4151.  
  4152.  
  4153.                 v
  4154.  
  4155.  
  4156.  
  4157.  
  4158.  
  4159.  
  4160.  
  4161.  
  4162.  
  4163.  
  4164.  
  4165.  
  4166.  
  4167.  
  4168.  
  4169.  
  4170.  
  4171.  
  4172.  
  4173.  
  4174.  
  4175.  
  4176.  
  4177.  
  4178.  
  4179.  
  4180.  
  4181.  
  4182.  
  4183.  
  4184.  
  4185.  
  4186.  
  4187.  
  4188.  
  4189.  
  4190.  
  4191.  
  4192.  
  4193.  
  4194.  
  4195.  
  4196.  
  4197.  
  4198.  
  4199.  
  4200.  
  4201.  
  4202.  
  4203.  
  4204.  
  4205.  
  4206.  
  4207.  
  4208.  
  4209.  
  4210.  
  4211.  
  4212.  
  4213.  
  4214.  
  4215.  
  4216.  
  4217.                 vi
  4218.  
  4219.  
  4220.  
  4221.  
  4222.  
  4223.  
  4224.  
  4225.  
  4226.  
  4227.  
  4228.  
  4229.  
  4230.                Tables
  4231.  
  4232.  
  4233.      Table 3.1: Possible Error Conditions  . . . . . . . .15
  4234.      Table 5.1: COM3 and COM4 Default Settings . . . . . .19
  4235.      Table 6.1: Basic Diskette Contents  . . . . . . . . .23
  4236.      Table 6.2: Optional Source Code . . . . . . . . . . .23
  4237.  
  4238.  
  4239.  
  4240.  
  4241.  
  4242.  
  4243.  
  4244.  
  4245.  
  4246.  
  4247.  
  4248.  
  4249.  
  4250.  
  4251.  
  4252.  
  4253.  
  4254.  
  4255.  
  4256.  
  4257.  
  4258.  
  4259.  
  4260.  
  4261.  
  4262.  
  4263.  
  4264.  
  4265.  
  4266.  
  4267.  
  4268.  
  4269.  
  4270.  
  4271.  
  4272.  
  4273.  
  4274.  
  4275.  
  4276.  
  4277.  
  4278.  
  4279.  
  4280.  
  4281.                 vii
  4282.